Wednesday 15 January 2014

c - "expected ')' before numeric constant" when calling sem_init -


Assign an OS programming using straightforward and posx threads. Here is my code:

  #include & lt; Pthread.h & gt; # Include & lt; Semaphore.h & gt; Sem_t mutex, to_b, to_a; Int main () {// Start semaphores sem_init (and mutex, 0, 1); Sem_init (and to_b, 0, 0); Sem_init (and to_a 0, 0); }   

gcc main.c -lpthread I'm getting the compilation:

  main.c: Main ': Main.c: 11: 24: error: expected') 'numeric constant before main.c: 11: 24: error: work on' sem_init '/usr/include/semaphore.h:37:12 Too few arguments: Note: Declared here   

With any idea what can this be? I'm definitely saying sem_init.

  sem_init (and to_a 0, 0);   

should be

  sem_init (and to_a, 0, 0);    

No comments:

Post a Comment