NULL vs 0 vs 0L bikeshed time
Thomas David Rivers
rivers at dignus.com
Mon Mar 1 05:17:31 PST 2004
>
> 1) Please restrain the need to bikeshed this one to death. I am
> sympathetic to technical arguments, but compulsive noise over
> such issues is annoying.
>
> 2) Please separate style disussion from technical discussion.
>
> I'd like to commit the following patch. It makes sure that for C
> and the kernel, NULL is a ((void *)0), and for C++, NULL is either
> (0L) or 0, with __LP64__ used to define the difference.
>
> The intent is to catch use of NULL where 0 or (0L) should be used.
> It generates extra warnings (I promise to fix these).
>
I believe that _may_ be backwards; the C and C++ standards
speak to this, and both of them have slightly different
requirements.
The C standard discuss the NULL constant, implying it is simply
a zero (not necessarily cast to a pointer.)
But - I believe (and I need to check on this) that the C++
standard requires the NULL constant to be a pointer type (so
various conversions work.)
So - before doing this; it might be nice to review the various
standards to see if it's applicable.
- Dave Rivers -
--
rivers at dignus.com Work: (919) 676-0847
Get your mainframe programming tools at http://www.dignus.com
More information about the freebsd-current
mailing list