A small issue with _GNU_SOURCE
Jon TURNEY
jon.turney@dronecode.org.uk
Thu Feb 19 14:33:00 GMT 2015
Consider the following:
$ cat test.c
#include <string.h>
int main()
{
strdup("test");
return ffsll(0);
}
ffsll() is a GNU extension and should be prototyped when _GNU_SOURCE is
defined.
strdup() is in SUSv2 and requires _XOPEN_SOURCE=500
$ gcc test.c -Wall -ansi -D_XOPEN_SOURCE=500
test.c: In function âmainâ:
test.c:8:2: warning: implicit declaration of function âffsllâ
I think this is correct
$ gcc test.c -Wall -ansi -D_GNU_SOURCE
Since _GNU_SOURCE implies _XOPEN_SOURCE=700, this is as expected.
$ gcc test.c -Wall -ansi -D_XOPEN_SOURCE=500 -D_GNU_SOURCE
test.c: In function âmainâ:
test.c:8:2: warning: implicit declaration of function âffsllâ
This looks like a problem with the way _GNU_SOURCE has been added to
newlib's sys/cdefs.h. _XOPEN_SOURCE causes _POSIX_C_SOURCE to be
defined, which prevents _GNU_SOURCE from being considered.
I'm not sure about the right way to fix this.
More information about the Newlib
mailing list