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.

Re: Help: data type sem_t 80 80

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.

Re: Help: data type sem_t 80 80

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.

Re: Help: data type sem_t 80 80

Use the semaphore.h library.

commented: dump 3-year old thread -7
Re: Help: data type sem_t 80 80

You forgot to include the semaphore.h library.

Be a part of the DaniWeb community

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