From owner-freebsd-arch Tue Aug 20 18:28:54 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 E486C37B400; Tue, 20 Aug 2002 18:28:49 -0700 (PDT) Received: from elvis.mu.org (elvis.mu.org [192.203.228.196]) by mx1.FreeBSD.org (Postfix) with ESMTP id AC34C43E6A; Tue, 20 Aug 2002 18:28:49 -0700 (PDT) (envelope-from baka@elvis.mu.org) Received: by elvis.mu.org (Postfix, from userid 1921) id 7A2EBAE163; Tue, 20 Aug 2002 18:28:49 -0700 (PDT) Date: Tue, 20 Aug 2002 18:28:49 -0700 From: Jon Mini To: Archie Cobbs Cc: obrien@FreeBSD.ORG, freebsd-arch@FreeBSD.ORG Subject: Re: NULL Message-ID: <20020821012849.GK3751@elvis.mu.org> References: <20020821002116.GA33223@dragon.nuxi.com> <200208210101.g7L110m03801@arch20m.dellroad.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200208210101.g7L110m03801@arch20m.dellroad.org> User-Agent: Mutt/1.3.27i 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 Archie Cobbs [archie@dellroad.org] wrote : > 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. 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. 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. I hope this makes sense. -- Jonathan Mini http://www.freebsd.org/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message