From owner-freebsd-hackers Fri Oct 11 1:34:54 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 229DC37B401; Fri, 11 Oct 2002 01:34:52 -0700 (PDT) Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9AF3843E65; Fri, 11 Oct 2002 01:34:50 -0700 (PDT) (envelope-from bde@zeta.org.au) Received: from bde.zeta.org.au (bde.zeta.org.au [203.2.228.102]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id SAA10239; Fri, 11 Oct 2002 18:34:42 +1000 Date: Fri, 11 Oct 2002 18:44:53 +1000 (EST) From: Bruce Evans X-X-Sender: bde@gamplex.bde.org To: Terry Lambert Cc: Craig Rodrigues , , Subject: Re: Problem detecting POSIX symbolic constants In-Reply-To: <3DA5D5BD.1DAFF031@mindspring.com> Message-ID: <20021011183032.D12170-100000@gamplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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 or , 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