delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2016/02/02/17:28:05

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:to:from:subject:message-id:date:mime-version
:content-type:content-transfer-encoding; q=dns; s=default; b=g4s
pMffLi8XlEFPObZ04jH6hf36EkB1fvCYsUzM6ypRarKt9HjL6kYbAi5oEswsAvuF
leKeXcGGwNmR6Dnrx9c16Ok0j4GDQLwUsUp4Hualio3QFxXnFwdPnf8/h/sHCNKH
G5VHdzSqe2cEsz236//hLpRYfCqAxNRZUm/Wkq68=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:to:from:subject:message-id:date:mime-version
:content-type:content-transfer-encoding; s=default; bh=DjCRTl64L
wwRMuN8vLyfil/lnDo=; b=K6cg8tJ9RMk9Xwnnd/GOzrNp+kwu3uskm3aAMRxdu
70bLKdFcIg+xoI08Bj3+TAZz9cm9n/AQPIuzvmWDzbq6Ikmh78j7OchX+sdT0Zl6
fvoaxDEiTFb6McAgpwGf9oNHYxEH4g7+VbUrZ1uE1XeJk4vnzKzXRifVVMXGGeP/
JA=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 spammy=H*r:sk:50-192-, H*RU:sk:50-192-, Hx-spam-relays-external:sk:50-192-, kitchen
X-HELO: limerock03.mail.cornell.edu
X-CornellRouted: This message has been Routed already.
To: cygwin <cygwin AT cygwin DOT com>
From: Ken Brown <kbrown AT cornell DOT edu>
Subject: Defining _GNU_SOURCE hides the declaration of aligned_alloc
Message-ID: <56B12D61.7030200@cornell.edu>
Date: Tue, 2 Feb 2016 17:27:45 -0500
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1
MIME-Version: 1.0
X-IsSubscribed: yes

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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019