From owner-freebsd-hackers Sat Oct 12 0:39:26 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 5B66537B401; Sat, 12 Oct 2002 00:39:18 -0700 (PDT) Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by mx1.FreeBSD.org (Postfix) with ESMTP id 42DAC43E8A; Sat, 12 Oct 2002 00:39:17 -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 RAA07511; Sat, 12 Oct 2002 17:39:09 +1000 Date: Sat, 12 Oct 2002 17:49:24 +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: <3DA72A53.9D2D61E5@mindspring.com> Message-ID: <20021012171803.F15910-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 Fri, 11 Oct 2002, Terry Lambert wrote: > Bruce Evans wrote: > > > 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. > > You mean "in preprocessor expressions", of course. Oop. I meant only one "in" in "being 0 in cpp in [sic] expressions". > > > 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. > > You can't depend on people using the standard C library via dlopen, > as opposed to, uh, "linking". Yes, a more careful reading of POSIX shows that if _POSIX_REALTIME_SIGNAL_ is undefined, then the (compile-time) system makes no claims as to the feature being either supported or unsupported. (Systems should leave it undefined it they are clueless about it.) The feature may still work at runtime, but the compile-time system makes no claims that it will or won't. Applications would have to do something magic to use it at runtime if it turns out to be present at runtime. It could easily be present at runtime because you update the OS. > > > Uh, the 1990 standard, which allowed "#if" is only 12 years old. > > > > #if is in K&R1 (1978). > > According to my first edition "The C Programming Language": > > 12.3 Conditional compilation > A compiler control line of the form > > #if constant-expression > > checks whether the constant expression (see section 15) > evaluates to non-zero. > > ... > > 15 Constant expressions > In several places C requires expressions which evaluate > to a constant: after case, as array bounds, and in initializers. > In the first two cases, the expression can involve only integer > constants, character constants, and sizeof expressions, possibly > connected by the binary operators > > + - * / % & | ^ << >> == != < > <= >= > > or by the unary operators > > - ~ > > or by the ternary operator > > ?: > > ...no "&&" or "||"... sorry. Also, "defined()" is not defined. > > I think you will find that "&&" and "||" in #if statements are > later extensions. > > The value of undefined macros in preprocessor expressions being > assumed to be zero is also not documented in the book. I would > have to imagine that they were not considered constant expressions. This book has lots of bugs (mostly from being too informal and/or omitting necessary details). Note that section 15 doesn't even mention "&&" and "||" working in non-cpp constant expressions. But they cetainly worked in expressions, and expressions with only constants in them are (informally) constant expessions. I think you are right that defined() didn't exist then. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message