From owner-freebsd-arch Tue Aug 20 18:15: 9 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 194B137B400; Tue, 20 Aug 2002 18:15:06 -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 8CD7343E42; Tue, 20 Aug 2002 18:15:05 -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 SAA88061; Tue, 20 Aug 2002 18:01:43 -0700 (PDT) Received: (from archie@localhost) by arch20m.dellroad.org (8.11.6/8.11.6) id g7L110m03801; Tue, 20 Aug 2002 18:01:00 -0700 (PDT) (envelope-from archie) From: Archie Cobbs Message-Id: <200208210101.g7L110m03801@arch20m.dellroad.org> Subject: Re: NULL In-Reply-To: <20020821002116.GA33223@dragon.nuxi.com> "from David O'Brien at Aug 20, 2002 05:21:16 pm" To: obrien@freebsd.org Date: Tue, 20 Aug 2002 18:01:00 -0700 (PDT) Cc: 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 David O'Brien writes: > > Simple question... > > Why isn't NULL defined to be "((void *)0)" instead of "0" ? > > In C++ this is not legal: > > void blah(void) { > int *foo; > void *bar; > bar = foo; > foo = bar; > } > > it is in C, but we share the definition. > A benefit of "(void *)0" is that this would be caught: > > char c = NULL; > > rather than the correct: > char c = '\0'; > When you say "not legal" do you mean it causes an error or a warning? If it's just a warning, then are you saying the reason we don't use (void *)0 is because we would lose the C++ warning to gain the C warning? Seems like a fair trade to me :-) FYI, this question came up when porting some code to redhat Linux, where NULL is defined as (void *)0. 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