From owner-freebsd-arch Tue Aug 20 18:45:11 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E633837B401; Tue, 20 Aug 2002 18:45:04 -0700 (PDT) Received: from InterJet.dellroad.org (adsl-63-194-81-26.dsl.snfc21.pacbell.net [63.194.81.26]) by mx1.FreeBSD.org (Postfix) with ESMTP id E89BA43E6E; Tue, 20 Aug 2002 18:45:03 -0700 (PDT) (envelope-from archie@dellroad.org) Received: from arch20m.dellroad.org (arch20m.dellroad.org [10.1.1.20]) by InterJet.dellroad.org (8.9.1a/8.9.1) with ESMTP id SAA88269; Tue, 20 Aug 2002 18:40:56 -0700 (PDT) Received: (from archie@localhost) by arch20m.dellroad.org (8.11.6/8.11.6) id g7L1eCJ03992; Tue, 20 Aug 2002 18:40:12 -0700 (PDT) (envelope-from archie) From: Archie Cobbs Message-Id: <200208210140.g7L1eCJ03992@arch20m.dellroad.org> Subject: Re: NULL In-Reply-To: <20020821012849.GK3751@elvis.mu.org> "from Jon Mini at Aug 20, 2002 06:28:49 pm" To: Jon Mini Date: Tue, 20 Aug 2002 18:40:12 -0700 (PDT) Cc: obrien@freebsd.org, freebsd-arch@freebsd.org X-Mailer: ELM [version 2.4ME+ PL88 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Jon Mini writes: > > When you say "not legal" do you mean it causes an error or a warning? > > > > FYI, this question came up when porting some code to redhat Linux, where > > NULL is defined as (void *)0. > > "Not legal" refers to the fact that C is a standardised language, > and this violates that standard. Whether or not it works in gcc is > irrellevant. You mean C++ right? That was the example being referred to. > Also, NULL is defined as 0 in the standard, because this: > > void *p; > > p = 0; > > Is guaranteed to produce an invalid pointer, and this: > > ((p != 0) || (p == 0)) > > Tests for a valid pointer and an invalid pointer, respectively. Are you saying that POSIX declares that NULL be "0"? Then I agree we must do that.. but why then doesn't Linux? Also, how does replacing "0" in your examples with "(void *)0" break anything? > The fact that pointers are linear addresses in FreeBSD and Linux > and that the address value 0x0 is used for NULL are just some of > the happy coincidences that the relevant standards can't rely on, > and must define as "implementation dependant." > > On a related note, this : > > p = 1; > > Is illegal. Agreed. > I hope this makes sense. Sortof.. :-) Thanks, -Archie __________________________________________________________________________ Archie Cobbs * Packet Design * http://www.packetdesign.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message