hi guys.
I don't get how to use semaphore in linux.
I am using ubuntu.
first of all, i have the following codes:
Code:
#include <semaphore.h>
sem_t sem;
int ret;
int count = 4;
/* to be shared among processes */
ret = sem_init(&sem, 1, count);
however when i complied the codes above, I got the following errors:
Code:
warning: data definition has no type or storage class
error: initializer element is not constant
what is wrong?
And another question, why can't I just use : semaphore mutex to declare?
like, semaphore mutex = 1;
thanks in advance.