standards/50889: NULL defined as 0 instead of (void *)0
M. Warner Losh
imp at bsdimp.com
Mon Apr 21 08:52:31 PDT 2003
In message: <20030421104840.GA92922 at falcon.midgard.homeip.net>
Erik Trulsson <ertr1013 at student.uu.se> writes:
: 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.
Strange, but legal, to catch more issues.
: > #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.
Yes, I didn't cut and paste, but rather typed from memory.
Warner
More information about the freebsd-standards
mailing list