* Fwd: A small issue with _GNU_SOURCE
[not found] <54E3808B.9040302@dronecode.org.uk>
@ 2015-02-17 18:25 ` Jon TURNEY
2015-02-17 21:43 ` Corinna Vinschen
0 siblings, 1 reply; 2+ messages in thread
From: Jon TURNEY @ 2015-02-17 18:25 UTC (permalink / raw)
To: cygwin-developers
Consider the following:
$ cat test.c
#include <string.h>
#include <stdlib.h>
int main()
{
long long i = random();
return ffsll(i);
}
ffsll() is a GNU extension and should be prototyped when _GNU_SOURCE is
defined.
random() is in SUSv2 and requires _XOPEN_SOURCE=500
$ gcc test.c -Wall -ansi -D_XOPEN_SOURCE=700
test.c: In function âmainâ:
test.c:8:2: warning: implicit declaration of function âffsllâ
This is correct
$ gcc test.c -Wall -ansi -D_XOPEN_SOURCE=700 -D_GNU_SOURCE
test.c: In function âmainâ:
test.c:8:2: warning: implicit declaration of function âffsllâ
This looks like a problem with newlib's sys/cdefs.h. _XOPEN_SOURCE
causes _POSIX_C_SOURCE to be defined, which prevents _GNU_SOURCE from
being considered.
$ gcc test.c -Wall -ansi -D_GNU_SOURCE
test.c: In function âmainâ:
test.c:7:2: warning: implicit declaration of function ârandomâ
_GNU_SOURCE is supposed to imply some value of _XOPEN_SOURCE, but only
actually turns on __XSI_VISIBLE.
The patch I wrote for cygwin's stdlib.h [1] explicitly checks
_XOPEN_SOURCE. Should this be a check for XSI_VISIBLE? or should
cdefs.h also define _XOPEN_SOURCE (and all the other feature test macros
that _GNU_SOURCE is defined to be equivalent to)?
[1] https://cygwin.com/ml/cygwin-patches/2013-q4/msg00004.html
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: A small issue with _GNU_SOURCE
2015-02-17 18:25 ` Fwd: A small issue with _GNU_SOURCE Jon TURNEY
@ 2015-02-17 21:43 ` Corinna Vinschen
0 siblings, 0 replies; 2+ messages in thread
From: Corinna Vinschen @ 2015-02-17 21:43 UTC (permalink / raw)
To: cygwin-developers
[-- Attachment #1: Type: text/plain, Size: 1747 bytes --]
On Feb 17 18:24, Jon TURNEY wrote:
>
> Consider the following:
>
> $ cat test.c
> #include <string.h>
> #include <stdlib.h>
>
> int main()
> {
> long long i = random();
> return ffsll(i);
> }
>
> ffsll() is a GNU extension and should be prototyped when _GNU_SOURCE is
> defined.
>
> random() is in SUSv2 and requires _XOPEN_SOURCE=500
>
> $ gcc test.c -Wall -ansi -D_XOPEN_SOURCE=700
> test.c: In function ‘main’:
> test.c:8:2: warning: implicit declaration of function ‘ffsll’
>
> This is correct
>
> $ gcc test.c -Wall -ansi -D_XOPEN_SOURCE=700 -D_GNU_SOURCE
> test.c: In function ‘main’:
> test.c:8:2: warning: implicit declaration of function ‘ffsll’
>
> This looks like a problem with newlib's sys/cdefs.h. _XOPEN_SOURCE causes
> _POSIX_C_SOURCE to be defined, which prevents _GNU_SOURCE from being
> considered.
>
> $ gcc test.c -Wall -ansi -D_GNU_SOURCE
> test.c: In function ‘main’:
> test.c:7:2: warning: implicit declaration of function ‘random’
>
> _GNU_SOURCE is supposed to imply some value of _XOPEN_SOURCE, but only
> actually turns on __XSI_VISIBLE.
>
> The patch I wrote for cygwin's stdlib.h [1] explicitly checks _XOPEN_SOURCE.
> Should this be a check for XSI_VISIBLE? or should cdefs.h also define
> _XOPEN_SOURCE (and all the other feature test macros that _GNU_SOURCE is
> defined to be equivalent to)?
The check should be one for XSI_VISIBLE. I'm not sure about cdefs.h,
though. Maybe you want to ask the question on the newlib ML? I'll
look into it tomorrow.
Thanks,
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat
[-- Attachment #2: Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-02-17 21:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <54E3808B.9040302@dronecode.org.uk>
2015-02-17 18:25 ` Fwd: A small issue with _GNU_SOURCE Jon TURNEY
2015-02-17 21:43 ` Corinna Vinschen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).