Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 11 Oct 2002 18:44:53 +1000 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        Terry Lambert <tlambert2@mindspring.com>
Cc:        Craig Rodrigues <rodrigc@attbi.com>, <freebsd-standards@FreeBSD.ORG>, <freebsd-hackers@FreeBSD.ORG>
Subject:   Re: Problem detecting POSIX symbolic constants
Message-ID:  <20021011183032.D12170-100000@gamplex.bde.org>
In-Reply-To: <3DA5D5BD.1DAFF031@mindspring.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 10 Oct 2002, Terry Lambert wrote:

> 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.

Undefined symbols being 0 in cpp in expressions was in early C compilers
if not the original one.  Consult your archives for a posting 10-15 years
or so ago by dmr in comp.std.c about him checking this in his archives.

> > > 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.

Symbols can be resolved at runtime using dlopen(), etc.  They would only
actually be available on systems where sysconf() says that they are.

> > > 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.

#if is in K&R1 (1978).

Bruce


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?20021011183032.D12170-100000>