From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 42909 invoked by alias); 2 Feb 2016 23:41:09 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 42809 invoked by uid 89); 2 Feb 2016 23:41:03 -0000 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 Received: from limerock01.mail.cornell.edu (HELO limerock01.mail.cornell.edu) (128.84.13.241) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 02 Feb 2016 23:41:03 +0000 X-CornellRouted: This message has been Routed already. Received: from authusersmtp.mail.cornell.edu (granite3.serverfarm.cornell.edu [10.16.197.8]) by limerock01.mail.cornell.edu (8.14.4/8.14.4_cu) with ESMTP id u12Nf0J4002373 for ; Tue, 2 Feb 2016 18:41:01 -0500 Received: from [10.13.22.4] (65-112-130-194.dia.static.qwest.net [65.112.130.194]) (authenticated bits=0) by authusersmtp.mail.cornell.edu (8.14.4/8.12.10) with ESMTP id u12Nexoj029184 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT) for ; Tue, 2 Feb 2016 18:41:00 -0500 Subject: Re: Defining _GNU_SOURCE hides the declaration of aligned_alloc To: cygwin@cygwin.com References: <56B12D61.7030200@cornell.edu> From: Ken Brown Message-ID: <56B13E8A.7080907@cornell.edu> Date: Tue, 02 Feb 2016 23:41:00 -0000 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> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-IsSubscribed: yes X-SW-Source: 2016-02/txt/msg00028.txt.bz2 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 > > 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