SIZEOF

Henry Spencer henry at utzoo.UUCP
Sat Feb 9 03:58:18 AEST 1985


> 		2. An object of integral type may be explicitly converted to a
> 		pointer...
> 
> Since compilers need to do type checking anyway, passing 0 instead of NULL
> should always be valid.

Wrong, you forgot the word "explicit".  That means *you* have to do it.
The compiler won't do it for you in parameter-passing.  Remember that
current C compilers do not (cannot) check types of parameters.

> Note that K&R says that assigning 0 to an integer
> generates the appropriate NULL pointer.  This type conversion (it is
> implied) is automagic, and thus there *is* a generic NULL, which is the
> integer 0.

For the 157th time, WRONG.  The only generic NULL pointer in C is the
*literal* integer *constant* 0.  An integer *value* equal to 0 is *not*
a NULL pointer; only the constant 0 will do.  Unless the character
"0" appears -- either explicitly or via "#define NULL 0" -- at the place
where the conversion to pointer is being performed, then it's not a real
NULL pointer.  If you read K&R carefully, you will discover that this is
what it really says.
-- 
				Henry Spencer @ U of Toronto Zoology
				{allegra,ihnp4,linus,decvax}!utzoo!henry



More information about the Comp.lang.c mailing list