Erreur compilation pthread_barrier_t Ubuntu
Bonjour,
Je suis sous ubuntu 10.10 et je n'arrive pas a compiler les programmes qui utilisent les outils pthread_barrier_t.
Voici un extrait de code simple qui ne compile pas chez moi.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
#include <pthread.h>
pthread_barrier_t bar;
int main()
{
pthread_barrierattr_t bar_attr;
pthread_barrierattr_init(&bar_attr);
pthread_barrier_init(&bar,&bar_attr,3);
pthread_barrierattr_destroy(&bar_attr);
pthread_barrier_destroy(&bar);
return 0;
} |
La commande compilation suivante : gcc -Wall -std=c99 -lpthread test.c
me renvoie les erreurs suivante :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
|
test.c:3: error: expected =, ,, ;, asm or __attribute__ before bar
test.c: In function main:
test.c:7: error: pthread_barrierattr_t undeclared (first use in this function)
test.c:7: error: (Each undeclared identifier is reported only once
test.c:7: error: for each function it appears in.)
test.c:7: error: expected ; before bar_attr
test.c:8: warning: implicit declaration of function pthread_barrierattr_init
test.c:8: error: bar_attr undeclared (first use in this function)
test.c:10: warning: implicit declaration of function pthread_barrier_init
test.c:10: error: bar undeclared (first use in this function)
test.c:12: warning: implicit declaration of function pthread_barrierattr_destroy
test.c:13: warning: implicit declaration of function pthread_barrier_destroy |
Par contre les autres méthodes de la library pthread sont reconnues et fonctionnent parfaitement.
Je sais que dans de nombreux cas il faut déclarer une macro à la compilation pour autoriser l'accès à certaines méthodes de la glibC. Exemple -D_XOPEN_SOURCE -D_POSIX_SOURCE en option de compilation.
J'ai googler mon problème sans trouver de réponse, et en plus pthread_barrier_t semble être supporté sous Ubuntu...
Quelqu'un a-t-il une idée?
Merci de votre aide.
Mith06