standards/50889: NULL defined as 0 instead of (void *)0

Bruce Evans bde at zeta.org.au
Wed Apr 16 08:00:56 PDT 2003


On Wed, 16 Apr 2003, Erik Trulsson wrote:

> On Wed, Apr 16, 2003 at 05:49:55AM -0700, Jens Schweikhardt wrote:
> > I agree, though, that it may be desirable to
> > #define NULL ((void*)0)
>
> Unless you want to use the same definition for both C and C++.
> In C++ the only valid way of defining NULL is
>
> #define NULL 0
>
> because in C++ there is no automatic conversion between "pointer to
> void" and other pointer types as there is in C.

I agree.  It may be, and is, also desireable to define NULL as 0.
A bit more desireable IMO.  Whichever detects the most bugs at compile
time is best.

Bruce


More information about the freebsd-standards mailing list