NULL vs 0

Guy Harris guy at rlgvax.UUCP
Sat Jan 21 11:35:24 AEST 1984


Unfortunately, NULL should *not* be (char *)0, because there is no such thing
as a generic null pointer in C.  Each type of pointer has its own flavor of
null pointer.  If you declare NULL as (char *)0, then if you pass NULL to a
routine which expects (int *)0, you will get a complaint from "lint" at best
and a dead program at worst - what if you have a word-addressed machine in
which (int *) takes 16 bits but (char *) takes 32?

	Guy Harris
	{seismo,ihnp4,allegra}!rlgvax!guy



More information about the Comp.unix.wizards mailing list