If I include both I get those errors I mentioned.
Here is a sample code that has the same prob
Code:
#include <semaphore.h>
#include <stdio.h>
#include <stdlib.h>
sem_t* start_race;
int main(void){
sem_unlink("start_race"); //remove se já existir
if (SEM_FAILED != start_race){
//sem_setvalue(start_race, 0, 0);
start_race = sem_open("start_race",O_CREAT|O_EXCL,0777,0);
}
else{
printf("Erro ao criar o semaforo start_race.\n");
exit(0);
}
}
Like that I get
Code:
namedSemaphores.c: In function `main':
namedSemaphores.c:11: error: `O_CREAT' undeclared (first use in this function)
namedSemaphores.c:11: error: (Each undeclared identifier is reported only once
namedSemaphores.c:11: error: for each function it appears in.)
namedSemaphores.c:11: error: `O_EXCL' undeclared (first use in this function)
With fcntl.h I get
Code:
/tmp/ccAx0hpm.o(.text+0x25): In function `main':
: undefined reference to `sem_unlink'
/tmp/ccAx0hpm.o(.text+0x47): In function `main':
: undefined reference to `sem_open'
collect2: ld returned 1 exit status
Please help! I don't know what more to do!