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.

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.

You forgot to include the semaphore.h library.