delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2016/02/02/18:41:25

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:subject:to:references:from:message-id:date
:mime-version:in-reply-to:content-type
:content-transfer-encoding; q=dns; s=default; b=dplDlVU+2Hzq9JA/
Cu4GcPsHsQYlcSdSnOHNC+RZ1d07BbLxiJhzMzUnFHK5rEUqcWaVigBTz5/bKzIj
NoOi4SKapQXpzw0CcgoaDZwrg0iR0QsBgdHRulFpAojfio5a5Qlw2Ne9yuIw+mCm
jK4esUHLtTHZjbRSw0p8OnzMR6o=
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:subject:to:references:from:message-id:date
:mime-version:in-reply-to:content-type
:content-transfer-encoding; s=default; bh=bi/zJAi3UHPvFmb1M0VnuR
WbfSM=; b=JVcjrKzkBzynRtMbE53cNC9D3gYVYuCcKSwk7udGqpH0/lMiXDXYoi
kv57VIIq5KgUWBuGlRSWa/X/h3utmPz90aojJJmZuKDE8whWaXfmdPLptWg1pskr
6c9nb617coFw1yxcxBxd4xKjZ7o04Toaf2bmGV8yu7oZ+Qgk7JrdM=
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.9 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 spammy=According, Defining, kitchen, H*f:sk:56B12D6
X-HELO: limerock01.mail.cornell.edu
X-CornellRouted: This message has been Routed already.
Subject: Re: Defining _GNU_SOURCE hides the declaration of aligned_alloc
To: cygwin AT cygwin DOT com
References: <56B12D61 DOT 7030200 AT cornell DOT edu>
From: Ken Brown <kbrown AT cornell DOT edu>
Message-ID: <56B13E8A.7080907@cornell.edu>
Date: Tue, 2 Feb 2016 18:40:58 -0500
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1
MIME-Version: 1.0
In-Reply-To: <56B12D61.7030200@cornell.edu>
X-IsSubscribed: yes

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

- Raw text -


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