This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Don't claim GCC predefines __POSIX__


On Fri, 17 Feb 2012, Alfred M. Szmidt wrote:

>    >> How do you test that you are on a POSIX compliant system?
>    >
>    > Practically, run autoconf tests for the features you care about,
>    > which are unlikely to be 100% conformance.  For 100% conformance,
>    > run a conformance testsuite - or if anyone does POSIX
>    > certification, look at a list of certified systems.
> 
>    I fully understand the complexity of saying a system is or is not
>    fully POSIX is not trivially detectable by the compiler.
> 
> One can get quite far by checking for __POSIX_VERSION__ as well if
> using autoconf tests is to heavy.

I presume you meant _POSIX_VERSION.  The previous paragraph of the manual 
(before the one I propose to remove) says:

  @strong{Usage Note:} Don't try to test whether the system supports POSIX
  by including @file{unistd.h} and then checking whether
  @code{_POSIX_VERSION} is defined.  On a non-POSIX system, this will
  probably fail because there is no @file{unistd.h}.  We do not know of
  @emph{any} way you can reliably test at compilation time whether your
  target system supports POSIX or whether @file{unistd.h} exists.

Maybe, given that you have POSIX, testing the version that way is more 
useful.

-- 
Joseph S. Myers
joseph@codesourcery.com

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]