A small issue with _GNU_SOURCE
Corinna Vinschen
vinschen@redhat.com
Wed Feb 25 17:31:00 GMT 2015
On Feb 25 16:04, Jon TURNEY wrote:
> 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.
>
> Done.
>
> But even now, I'm not sure this is quite right.
>
> $ cat test.c
>
> #include <string.h>
>
> int main()
> {
> strdup("test");
> 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...
That's how it is in Glibc, but AFAICS, not on the BSDs. For instance,
OpenBSD defines this as:
#ifdef _POSIX_C_SOURCE
# if (_POSIX_C_SOURCE - 0 >= 200809)
# define __POSIX_VISIBLE 200809
# define __ISO_C_VISIBLE 1999
[...etc...]
#if defined(_ANSI_SOURCE) && !defined(__POSIX_VISIBLE) && \
!defined(__XPG_VISIBLE)
# define __POSIX_VISIBLE 0
# define __XPG_VISIBLE 0
# define __ISO_C_VISIBLE 1990
#endif
So __POSIX_VISIBLE and __XPG_VISIBLE override strict ANSI, isn't it?
Can somebody with access to a BSD system test this, perhaps?
Thanks,
Corinna
--
Corinna Vinschen
Cygwin Maintainer
Red Hat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/newlib/attachments/20150225/972bf415/attachment.sig>
More information about the Newlib
mailing list