Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 21 Apr 2003 12:48:40 +0200
From:      Erik Trulsson <ertr1013@student.uu.se>
To:        "M. Warner Losh" <imp@bsdimp.com>
Cc:        schweikh@freebsd.org
Subject:   Re: standards/50889: NULL defined as 0 instead of (void *)0
Message-ID:  <20030421104840.GA92922@falcon.midgard.homeip.net>
In-Reply-To: <20030421.020106.41513803.imp@bsdimp.com>
References:  <20030416125715.GA12300@falcon.midgard.homeip.net> <20030417005708.D6167@gamplex.bde.org> <20030416172723.GA13575@falcon.midgard.homeip.net> <20030421.020106.41513803.imp@bsdimp.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Apr 21, 2003 at 02:01:06AM -0600, M. Warner Losh wrote:
> I have a #define in my tree that I switch back and forth from time to
> time:
> 
> #if defined(_cplusplus) || !defined(_NULL_VOID)
> #define NULL 0L

Why not just plain 0?
I think either will work fine so it doesn't matter really matter much
but I am a bit curious.

> #else
> #define NULL (void *) 0

Won't work correctly.  You need to use ((void*)0) instead with the
extra parenthesis.  Otherwise expressions like 'sizeof NULL' will fail
to compile.

> #endif
> 
> and I add -D_NULL_VOID to build when I want to detect problems that
> (void *) 0 detects, then switch it back to 0 for the problems that
> that detects.
> 
> You can't win here.  I'd be inclined to leave things as the status quo.

I agree completely with that.


-- 
<Insert your favourite quote here.>
Erik Trulsson
ertr1013@student.uu.se



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030421104840.GA92922>