Date: Sun, 20 Oct 2002 15:24:04 -0700 (PDT) From: Don Lewis <dl-freebsd@catspoiler.org> To: imp@bsdimp.com Cc: freebsd-standards@FreeBSD.ORG, freebsd-hackers@FreeBSD.ORG Subject: Re: Problem detecting POSIX symbolic constants Message-ID: <200210202224.g9KMO4vU074848@gw.catspoiler.org> In-Reply-To: <20021020.143416.109047247.imp@bsdimp.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On 20 Oct, M. Warner Losh wrote: > My copy of K&R 1 is silent on this issue (well, as I recall, I can't > find my K&R1 at the moment), which means defined isn't likely to be > there. My copy of the Bell Laboratories Technical Journal October > 1984 (Vol 63 No.8 Part 2) says, in "The Evolution of C -- Past and > Future" by L. Rosler, section 5.9 Compiler Control Lines: > > The conditional-compile facility (Ref 2. Sect 12.3) has been > enhanced in two ways. > > To facilitate selection of one among a set of choices, any > number of control lines of the form > #elif constant-expression > may now appear on any line between a #if line and its closing > #endif (or #else if present). > > The new pseudofunction defined(identifier) may be used in the > constant-expression part of a #if or #elif control line, with > value 1 if the identifier is currently defined in the > preprocessor, and 0 otherwise. Thus #ifdef identifier is > equivalent to #if defined(identifier) and #ifndef identifier > is equivalent to #if !defined(identifier). The older forms > will be retained for compatibility, as they are deeply > entrenched in existing code. But, as they are superfluous, > equivalents to #ifdef will not be provided for the new > construction #elif. > > Ref 2 looks to be K&R1: > 2. B. W. Kernighan and D. M. Ritchie, The C Programming > Language, Englewood Cliffs, NJ.: Prentice Hall, 1978. That's K&R 1 and my copy doesn't mention anything about #elif or defined(). Unlike one compiler I used in the bad old days, it does have #if, which it documents as using a constant expression and provides a pointer to another section of the chapter. The constant expression section mentions integer and character constants, and sizeof expressions, as well as the unary, binary, and ternary operators. No mention of defined() ... To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200210202224.g9KMO4vU074848>