From: Ken Brown <kbrown@cornell.edu>
To: cygwin@cygwin.com
Subject: Re: Defining _GNU_SOURCE hides the declaration of aligned_alloc
Date: Tue, 02 Feb 2016 23:41:00 -0000 [thread overview]
Message-ID: <56B13E8A.7080907@cornell.edu> (raw)
In-Reply-To: <56B12D61.7030200@cornell.edu>
On 2/2/2016 5:27 PM, Ken Brown wrote:
> The issue in the Subject line came up in connection with an emacs bug
> report.
>
> Here's a test case:
>
> $ cat test.c
> #define _GNU_SOURCE
> #include <stdlib.h>
>
> int
> main ()
> {
> aligned_alloc (1, 1);
> }
>
> $ gcc test.c -Wimplicit-function-declaration
> test.c: In function âmainâ:
> test.c:7:3: warning: implicit declaration of function âaligned_allocâ
>
> The cause is that the declaration of aligned_alloc in stdlib.h is
> guarded by #if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L; but
> defining _GNU_SOURCE causes __ISO_C_VISIBLE to be defined as 1999.
> Here's an excerpt from /usr/include/sys/cdefs.h showing how this happens:
>
> /* Deal with _GNU_SOURCE, which implies everything and the kitchen sink */
> #ifdef _GNU_SOURCE
> [...]
> #define _XOPEN_SOURCE 700
> [...]
> #endif
> [...]
> #if _XOPEN_SOURCE - 0 >= 700
> [...]
> #define _POSIX_C_SOURCE 200809
> [...]
> #endif
> [...]
> #if _POSIX_C_SOURCE >= 200809
> [...]
> #define __ISO_C_VISIBLE 1999
> [...]
> #endif /* _POSIX_C_SOURCE */
>
> According to the discussion of the emacs bug I mentioned, Linux and
> FreeBSD don't have this issue. Should Cygwin's headers be changed to
> conform to those other platforms?
Paul Eggert says they should:
> Defining _GNU_SOURCE should make aligned_alloc visible regardless of whether -std=c99 is specified. This is because defining _GNU_SOURCE means, "Make GNU symbols visible even when compiling pedantically." This is OK, since the C standard says the behavior is undefined whenever the user defines a reserved symbol like _GNU_SOURCE.
Ken
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
next prev parent reply other threads:[~2016-02-02 23:41 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-02 22:27 Ken Brown
2016-02-02 23:41 ` Ken Brown [this message]
2016-02-03 3:15 ` Yaakov Selkowitz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=56B13E8A.7080907@cornell.edu \
--to=kbrown@cornell.edu \
--cc=cygwin@cygwin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).