Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 10 Oct 2002 12:32:13 -0700
From:      Terry Lambert <tlambert2@mindspring.com>
To:        Bruce Evans <bde@zeta.org.au>
Cc:        Craig Rodrigues <rodrigc@attbi.com>, freebsd-standards@FreeBSD.ORG, freebsd-hackers@FreeBSD.ORG
Subject:   Re: Problem detecting POSIX symbolic constants
Message-ID:  <3DA5D5BD.1DAFF031@mindspring.com>
References:  <20021010205529.M8598-100000@gamplex.bde.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Bruce Evans wrote:
> In Standard C, this is equivalent to the non-verbose version:
> 
>         #if _POSIX_REALTIME_SIGNALS != -1
>         ...
>         #endif
> 
> since if _POSIX_REALTIME_SIGNALS is not defined then it is equivalent to
> 0 in cpp expressions.  The problem cases are if _POSIX_REALTIME_SIGNALS
> is defined to <empty> or <garbage>, but these are not permitted in
> POSIX.1-2001.  These cases were permitted for many feature test macros
> in POSIX.1-1990.

I know it's not fashionable to write code that's portable to
compilers other than GCC, but even if FreeBSD is going to ignore
portability for it's own source code, it's probably unreasonable
to expect ACE to ignore portability for theirs.

> > Sigh.  Why did the POSIX guys do this? :(
> 
> Perhaps because they wanted you to use sysconf() instead of these mistakes.
> Actually, they didn't do this.  _POSIX_REALTIME_SIGNALS is specified to
> have value 0, -1 or 200xxxL (draft 7 says xxx; I think the final standard
> says 112).

This can't be the case; specifically, the sysconf() test will
only work at runtime, which means that the symbols had to be
there and resolvable at link time.

Unless you know some preprocessor directive to access the
"sysconf" space?


> > BTW, I think that:
> > #if defined(_POSIX_REALTIME_SIGNALS) && (_POSIX_REALTIME_SIGNALS != -1 )
> >
> > should suffice, but I'll double-check with one of my portability gurus
> > to see if that is OK for ACE.
> 
> This is variant of the above verbose version.  It requires slightly more
> modern compilers, so it might fail for some 20-year old pre-Standard C
> compilers instead of only for some 25-year old ones.

Uh, the 1990 standard, which allowed "#if" is only 12 years old.

-- Terry

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3DA5D5BD.1DAFF031>