Bug#402318: libc6-dev: /usr/include/semaphore.h can't be used without pthread.h
Florian Le Goff a écrit :
There is an issue with the /usr/include/semaphore.h file and what
the manpages are saying for sem_open(3) and POSIX specifications
for the semaphore.h file.
In a nutshell, with the libc6-dev package, one can't do
the (basic) following :
Without having included pthread.h before. That breaks a few
.c files that would have compiled without any error on other POSIX
systems with the following message :
In file included from test.c:10:
/usr/include/semaphore.h:34: error: field '__sem_lock' has incomplete
(where line 10 of test.c is "#include <semaphore.h>").
Maybe should we inlcude pthread.h in /usr/include/semaphore.h ?
I don't have this problem here. /usr/include/semaphore.h includes
sys/types.h which includes bits/pthreadtypes.h, which defines
You're right. I missed an -ansi in my $CFLAGS (see below).
Could you please send me a testcase and the compilation options you used?
Here it is :
> ble ~/bl $ cat test.c
> #include <semaphore.h>
> int main()
> return 0;
With -ansi, it fails :
> ble ~/bl $ cc -W -ansi -Wall -Werror -o test test.c
> In file included from test.c:1:
> /usr/include/semaphore.h:34: error: field '__sem_lock' has
> incomplete type
> ble ~/bl $
But, if I include <pthread.h> before <semaphore.h>, the -ansi flag does
not cause any error nor warning.
Without, it works flawlessly :
ble ~/bl $ cc -W -Wall -Werror -o test test.c
ble ~/bl $
Florian Le Goff