NULL as a pointer value...

Andrew Stewart andrew at hwcs.UUCP
Fri Jul 13 04:10:52 AEST 1984


I am in the depths of yet another discussion about types in C, and I'm
looking for comments, etc. on this:
	Which is better coding style,
		char	*x; .....  x = (char *)NULL;
	or
		char	*x; .....  x = NULL;
I am unhappy about NULL as a polymorphic pointer type, since it's actually
just a macro, *but* is that relevant? K&R say (can't recall where) that
NULL is an illegal pointer for *any* object, and yet
		x = NULL; .... y = *x;
will not blow up, unless you do clever things with page 0.
And what about
		return((char *)NULL);
	or
		return(NULL);

This may have been aired before - if so, forgive me - but it seems
rather interesting.

----------------
"Not a bug, a feature! It's documented, dash it!"
	Andrew Stewart.
	...!vax135!ukc!edcaad!hwcs!andrew	(UUCP)



More information about the Comp.unix.wizards mailing list