From owner-freebsd-standards Sun Oct 20 15:24:25 2002 Delivered-To: freebsd-standards@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3A71037B401; Sun, 20 Oct 2002 15:24:24 -0700 (PDT) Received: from gw.catspoiler.org (217-ip-163.nccn.net [209.79.217.163]) by mx1.FreeBSD.org (Postfix) with ESMTP id 602DE43E6E; Sun, 20 Oct 2002 15:24:23 -0700 (PDT) (envelope-from dl-freebsd@catspoiler.org) Received: from mousie.catspoiler.org (mousie.catspoiler.org [192.168.101.2]) by gw.catspoiler.org (8.12.5/8.12.5) with ESMTP id g9KMO4vU074848; Sun, 20 Oct 2002 15:24:07 -0700 (PDT) (envelope-from dl-freebsd@catspoiler.org) Message-Id: <200210202224.g9KMO4vU074848@gw.catspoiler.org> Date: Sun, 20 Oct 2002 15:24:04 -0700 (PDT) From: Don Lewis Subject: Re: Problem detecting POSIX symbolic constants To: imp@bsdimp.com Cc: freebsd-standards@FreeBSD.ORG, freebsd-hackers@FreeBSD.ORG In-Reply-To: <20021020.143416.109047247.imp@bsdimp.com> MIME-Version: 1.0 Content-Type: TEXT/plain; charset=us-ascii Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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