This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

A small issue with _GNU_SOURCE



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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]