mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@aerifal.cx>
To: musl@lists.openwall.com
Subject: Re: musl detection by preprocessor
Date: Fri, 8 Feb 2013 15:19:30 -0500	[thread overview]
Message-ID: <20130208201930.GL20323@brightrain.aerifal.cx> (raw)
In-Reply-To: <1360354336.2983.395.camel@eris.loria.fr>

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


      reply	other threads:[~2013-02-08 20:19 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-08 16:28 Jens Gustedt
2013-02-08 16:41 ` Szabolcs Nagy
2013-02-08 16:51   ` Jens Gustedt
2013-02-08 17:07     ` Szabolcs Nagy
2013-02-08 18:55     ` Rich Felker
2013-02-08 20:12       ` Jens Gustedt
2013-02-08 20:19         ` Rich Felker [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130208201930.GL20323@brightrain.aerifal.cx \
    --to=dalias@aerifal.cx \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).