Hello, there. I'm having trouble with the initialization of variable of type sem_t.

I used this.

sem_t example;

example = NULL;

if(example == NULL){
    /* code here */
}

I'm getting the error, "no match for operator ==".

What value do you think I should place in the initialization?

I tried 0, but still the same.

Thanks.

Recommended Answers

All 5 Replies

probably because you have not defined sem_t -- I never heard of it. If its an integer then assigning NULL to it is incorrect -- NULL is used for pointers, just use 0 to initialize integers.

I realize this is an old thread but I think I may be able to help...when you initialize sem_t you need to use the function

int sem_init( sem_t * sem, int pshared, unsigned value );

then use the return value of the function instead of comparing the actual value of the sem_t variable.

Use the semaphore.h library.

commented: dump 3-year old thread -7

You forgot to include the semaphore.h library.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.