A small issue with _GNU_SOURCE

Jon TURNEY jon.turney@dronecode.org.uk
Wed Feb 25 17:29:00 GMT 2015

On 24/02/2015 13:28, Corinna Vinschen wrote:
> On Feb 24 12:46, Jon TURNEY wrote:
>> 	* libc/include/sys/cdefs.h (_GNU_SOURCE): Move check so it has an
>> 	effect when _XOPEN_SOURCE is also defined.
> Looks good, with a single nit:

>> +/* Deal with _GNU_SOURCE, which implies everything and the kitchen sink */
>> +#ifdef _GNU_SOURCE
> Before defining _XOPEN_SOURCE this should undef _XOPEN_SOURCE to avoid
> potential compiler warnings about a redefined macro.  With this change,
> please apply.


But even now, I'm not sure this is quite right.

$ cat test.c

#include <string.h>

int main()
  return ffsll(0);

$ gcc test.c -Wall -ansi
test.c: In function ‘main’:
test.c:7:2: warning: implicit declaration of function ‘ffsll’

I think this should also warn about no prototype for strdup(), because 
that shouldn't be in scope due to __STRICT_ANSI__, which cdefs.h doesn't 
even consider...

More information about the Newlib mailing list