public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Defining _GNU_SOURCE hides the declaration of aligned_alloc
@ 2016-02-02 22:27 Ken Brown
  2016-02-02 23:41 ` Ken Brown
  2016-02-03  3:15 ` Yaakov Selkowitz
  0 siblings, 2 replies; 3+ messages in thread
From: Ken Brown @ 2016-02-02 22:27 UTC (permalink / raw)
  To: cygwin

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?

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-02-03  3:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-02 22:27 Defining _GNU_SOURCE hides the declaration of aligned_alloc Ken Brown
2016-02-02 23:41 ` Ken Brown
2016-02-03  3:15 ` Yaakov Selkowitz

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).