From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/2754 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: musl detection by preprocessor Date: Fri, 8 Feb 2013 15:19:30 -0500 Message-ID: <20130208201930.GL20323@brightrain.aerifal.cx> References: <1360340887.2983.352.camel@eris.loria.fr> <20130208164134.GV6181@port70.net> <1360342301.2983.361.camel@eris.loria.fr> <20130208185517.GI20323@brightrain.aerifal.cx> <1360354336.2983.395.camel@eris.loria.fr> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1360354790 4206 80.91.229.3 (8 Feb 2013 20:19:50 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 8 Feb 2013 20:19:50 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-2755-gllmg-musl=m.gmane.org@lists.openwall.com Fri Feb 08 21:20:10 2013 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1U3uQT-00081e-Cn for gllmg-musl@plane.gmane.org; Fri, 08 Feb 2013 21:20:01 +0100 Original-Received: (qmail 27911 invoked by uid 550); 8 Feb 2013 20:19:42 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 27903 invoked from network); 8 Feb 2013 20:19:42 -0000 Content-Disposition: inline In-Reply-To: <1360354336.2983.395.camel@eris.loria.fr> User-Agent: Mutt/1.5.21 (2010-09-15) Xref: news.gmane.org gmane.linux.lib.musl.general:2754 Archived-At: On Fri, Feb 08, 2013 at 09:12:16PM +0100, Jens Gustedt wrote: > > I'm not sure how you can determine with just the standard macros that > > you're on a POSIX or POSIX-like system where you have unistd.h... > > Sure, usually you have to provide that information on the commandline > or through extensions (such as -std=gnu99). On POSIX systems you have > the getconf tool that provides reliable information about the > system: > > getconf _POSIX_VERSION > > should always work. If you're on a system that has a shell, command line utilities, and makefiles, it almost certainly has unistd.h, in which case including unistd.h can tell you about which standards it supports. > I probably have to review my include ordering a bit, currently I > set __GNUC_SOURCE *before* including unistd.h. I understood from their > docs that this is the way it is meant to be. Only by having it defined > before, I will in fact see the extensions they provide. Yes. The _*_SOURCE macros (called feature test macros, a rather confusing name) are meant to be defined by the application to request a particular featureset or conformance profile from the implementation. Note that the standards require them to be defined before _any_ system header is included, since it's possible (as in glibc and its features.h) that they're processed only once, at the time of the first inclusion of a system header. But it's also possible that they're processed at the time of each header's inclusion. The only portable way to use them is to define them before including any system headers. Rich