From owner-freebsd-hackers Sun Oct 20 13:34:32 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 8685537B401; Sun, 20 Oct 2002 13:34:30 -0700 (PDT) Received: from harmony.village.org (rover.bsdimp.com [204.144.255.66]) by mx1.FreeBSD.org (Postfix) with ESMTP id DEE6A43E91; Sun, 20 Oct 2002 13:34:28 -0700 (PDT) (envelope-from imp@bsdimp.com) Received: from localhost (warner@rover2.village.org [10.0.0.1]) by harmony.village.org (8.12.3/8.12.3) with ESMTP id g9KKYSpk076185; Sun, 20 Oct 2002 14:34:28 -0600 (MDT) (envelope-from imp@bsdimp.com) Date: Sun, 20 Oct 2002 14:34:16 -0600 (MDT) Message-Id: <20021020.143416.109047247.imp@bsdimp.com> To: freebsd-standards@FreeBSD.ORG, freebsd-hackers@FreeBSD.ORG Subject: Re: Problem detecting POSIX symbolic constants From: "M. Warner Losh" In-Reply-To: <20021020204920.C8767@chiark.greenend.org.uk> References: <20021016121455.A3711@chiark.greenend.org.uk> <20021020.134409.73085448.imp@bsdimp.com> <20021020204920.C8767@chiark.greenend.org.uk> X-Mailer: Mew version 2.1 on Emacs 21.2 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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 In message: <20021020204920.C8767@chiark.greenend.org.uk> Tony Finch writes: : On Sun, Oct 20, 2002 at 01:44:09PM -0600, M. Warner Losh wrote: : > Tony Finch writes: : > : On Sat, Oct 12, 2002 at 01:20:03PM -0700, Terry Lambert wrote: : > : > : > : > #if _DEFINED_SUPPORTED && defined(SOMETHING) : > : : > : That's a syntax error in pre-ANSI preprocessors (unless defined() is : > : #defined), which won't be bypassed by evaluation shortcutting since : > : evaluation happens after parsing. : > : > Actaully, it is only a syntax error on some really really really old : > cpp. The sun cpp on SunOS 4.x, for example, wasn't ANSI, but did grok : > the above construct. : : Yes, the C manual in -CURRENT which sates from 1986 documents defined(). : I haven't found any versions of the manual between 1975 (h0h0 C) and : then, and I don't have a copy of K&R 1 :-/ I can verify first hand that SunOS 3.5 (and I think 3.2) behaved the same way as SunOS 4.1.3 did. 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. So it looks like it was added just after K&R1, but early enough that 4.2BSD had it (and maybe earlier), which would explain why SunOS groks it. 1984 definitely pre-dates the standard (and in fact this same article goes on to describe varadic functions with a syntax that is different than what was finally adapoted). Warner To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message