This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
bsd_signal's prototype unavailable when _GNU_SOURCE is defined
- From: Ponnuvel Palaniyappan <pponnuvel at gmail dot com>
- To: libc-help at sourceware dot org
- Date: Sat, 11 Nov 2017 01:01:47 +0000
- Subject: bsd_signal's prototype unavailable when _GNU_SOURCE is defined
- Authentication-results: sourceware.org; auth=none
Man page of bsd_signal says:
> bsd_signal():
> Since glibc 2.26:
> _XOPEN_SOURCE >= 500
> && ! (_POSIX_C_SOURCE >= 200112L)
> Glibc 2.25 and earlier:
> _XOPEN_SOURCE
Defining those two macros as such works. But when I define _GNU_SOURCE
additionally, it doesn't work. The following demonstrates the problem:
```
$ cat x.c
#include <signal.h>
int main(void)
{
bsd_signal(0, 0);
}
$ gcc -D_XOPEN_SOURCE=500 -D_POSIX_C_SOURCE=199506L -std=gnu99 x.c
$ gcc -D_XOPEN_SOURCE=500 -D_POSIX_C_SOURCE=199506L -std=gnu99
-D_GNU_SOURCE x.c
x.c: In function ‘main’:
x.c:4:5: warning: implicit declaration of function ‘bsd_signal’; did you
mean ‘ssignal’? [-Wimplicit-function-declaration]
bsd_signal(0, 0);
^~~~~~~~~~
ssignal
As seen above, defining _GNU_SOURCE makes bsd_signal unavailable, it works
when _XOPEN_SOURCE and _POSIX_C_SOURCE are defined as man page says.
But defining _GNU_SOURCE appears to interfere. IIRC, this problem didn't
exist up until glibc 2.24.
Is this the expected behaviour? If so, is there a way to make bsd_signal
available whiling _GNU_SOURCE is defined?
Compiled using gcc 7.2.0/glibc 2.26 on Ubuntu 17.10.
Thanks.