From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3315 invoked by alias); 5 Apr 2017 23:39:51 -0000 Mailing-List: contact newlib-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: newlib-owner@sourceware.org Received: (qmail 2495 invoked by uid 89); 5 Apr 2017 23:39:50 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=1.8 required=5.0 tests=BAYES_50,KAM_LAZY_DOMAIN_SECURITY autolearn=no version=3.3.2 spammy=H*RU:sk:mail.co, Hx-spam-relays-external:sk:mail.co, H*r:sk:mail.co, HX-HELO:sk:mail.co X-HELO: mail.contemporary.net.au Received: from msc1401703.lnk.telstra.net (HELO mail.contemporary.net.au) (139.130.245.200) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 05 Apr 2017 23:39:47 +0000 Received: from [10.10.5.3] (kiwi.contemporary.net.au [10.10.5.3]) (authenticated bits=0) by mail.contemporary.net.au (8.14.9/8.14.7) with ESMTP id v35NdLmP053569 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Thu, 6 Apr 2017 09:39:21 +1000 (EST) (envelope-from chrisj@rtems.org) Subject: Re: C++ and feature guards Warning Question To: Joel Sherrill , "newlib@sourceware.org" References: From: Chris Johns Message-ID: Date: Wed, 05 Apr 2017 23:39:00 -0000 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2017/txt/msg00280.txt.bz2 On 06/04/2017 07:18, Joel Sherrill wrote: > > Trying to compile an open source package for RTEMS, I > came across something I need help to figure out how > best to address. The package is in C++ and giving a > lot of warnings on methods which I would have thought > are prototyped. But clearly the compiler settings > are tripping the guards different than the package > authors expect. > > Native GCC on CentOS 7 with glibc gives no warnings. > It could easily be a GCC version side-effect. > > ========================== > #include > > int f(char *s) > { > return mkstemp(s); > } > ========================== > > Warnings with i386-rtems GCC and newilb: > > $ i386-rtems4.12-gcc -c j.cc > $ i386-rtems4.12-gcc -std=c++11 -c j.cc > j.cc: In function 'int f(char*)': > j.cc:5:19: error: 'mkstemp' was not declared in this scope > return mkstemp(s); > $ i386-rtems4.12-gcc -std=c++03 -c j.cc > j.cc: In function 'int f(char*)': > j.cc:5:19: error: 'mkstemp' was not declared in this scope > return mkstemp(s); > $ i386-rtems4.12-gcc --version > i386-rtems4.12-gcc (GCC) 6.3.0 20161221 (RTEMS 4.12, RSB > 4c5eb8969451c4ea0997b3caa98bfe80fe15da69, Newlib 2.5.0.20170228) > > Native GCC and glibc results: > > $ gcc -std=c++03 -c j.cc > $ gcc -std=c++11 -c j.cc > $ gcc -std=c++11 ^C j.cc > $ gcc --version > gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-11) > > Suggestions on what to do to eliminate the warnings is > appreciated. > I built the code on FreeBSD with clang and the result is the same as Linux: $ cc -std=c++03 -c j.cc $ cc -std=c++11 -c j.cc $ cc --version FreeBSD clang version 3.8.0 (tags/RELEASE_380/final 262564) (based on LLVM 3.8.0) Target: x86_64-unknown-freebsd11.0 Thread model: posix InstalledDir: /usr/bin Adding -save-temps to the builds I see `mkstemp` is guarded with: #if __MISC_VISIBLE || __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE >= 4 and FreeBSD has: #if __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE I hope this helps. Chris