NULL vs 0

gwyn%brl-vld at sri-unix.UUCP gwyn%brl-vld at sri-unix.UUCP
Sun Feb 5 12:52:17 AEST 1984


From:      Doug Gwyn (VLD/VMB) <gwyn at brl-vld>

In C, 0 is explicitly NOT ALLOWED to be a pointer to actual data.

The C Standards Committee seems to be inclined to support declaration
of procedure parameters, along with automatic coercion of arguments to
the declared type.  I am not happy with automatic coercion as I think
it encourages sloppy coding, but at least it would let you blissfully
supply 0 as a pointer argument and have the compiler turn it into the
correct width of null pointer.  However, this would not work for such
functions as execl() where it is not possible to declare the type of
all parameters, so you would still have to use (char *)0 as an execl()
argument list terminator.

I really don't see what all the discussion is about.  Just use the
appropriately typecast 0 where you need a null pointer in your C code
and you have taken care of the matter for once and for all.



More information about the Comp.unix.wizards mailing list