This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
A small issue with _GNU_SOURCE
- From: Jon TURNEY <jon dot turney at dronecode dot org dot uk>
- To: newlib at sourceware dot org
- Date: Thu, 19 Feb 2015 14:02:13 +0000
- Subject: A small issue with _GNU_SOURCE
- Authentication-results: sourceware.org; auth=none
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.