Please use NULL instead of 0 whenever you have a pointer!

gwyn%brl-vld at sri-unix.UUCP gwyn%brl-vld at sri-unix.UUCP
Mon Jan 16 18:46:02 AEST 1984


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

However, zero pointers come in several different sizes in some
implementations of C, with (char *) guaranteed to be the widest.
This means that passing an actual argument of 0 to a function
expecting a pointer may not necessarily work, unless the zero is
explicitly type-cast to the corresponding pointer type.  E.g.,
	func( (struct foo *)0, more_args );
or
	func( (struct foo *)NULL, more_args );
rather than
	func( 0, more_args );
or
	func( NULL, more_args );
if the first formal parameter of foo() is declared a (struct foo *).



More information about the Comp.unix.wizards mailing list