use of NULL

heather at SEAS.UCLA.EDU heather at SEAS.UCLA.EDU
Fri Feb 24 03:29:06 AEST 1989


In article <9684 at smoke.BRL.MIL> gwyn at brl.arpa (Doug Gwyn (VLD/VMB) <gwyn>) writes:
>In article <973 at optilink.UUCP> cramer at optilink.UUCP (Clayton Cramer) writes:
>>Never pass bare 0 as a pointer argument -- but use the stdio.h
>>definition of NULL, and the segmented architecture will NOT screw
>>you.
>
>Wrong.  Use of uncast NULL as an argument to a function is never correct
>usage; although you can get away with it sometimes, it only "works" by
>accident and may quit working suddenly if the implementation changes.
>It is definitely not portable.  Always cast 0 or NULL to the correct
>pointer type when used as a function argument.

Excuse me for a probably naive question that I've had since following the
discussion of passing NULL to functions: Why doesn't the C standard
treat NULL or 0 (a static/constant NULL or 0, i.e. indicated at compile time)
passed to a function that has a pointer value in the function prototype 
as a special case and do the cast implicitly?

Heather Burris, UCLA



More information about the Comp.lang.c mailing list