pointers, tests, casts

david wald wald-david at CS.YALE.EDU
Mon Dec 5 10:22:10 AEST 1988


In article <9038 at smoke.BRL.MIL> gwyn at brl.arpa (Doug Gwyn (VLD/VMB) <gwyn>) writes:
>In article <44100016 at hcx3> shirono at hcx3.SSD.HARRIS.COM writes:
>>Even in the K&R1 days, the only valid definition of NULL has been
>>#define NULL 0
>
>True of pre-ANSI C, but an ANSI C implementation can use either that
>definition or
>#define NULL ((void*)0)
>I recommend the former even for ANSI C implementations.  The added
>complexity buys just one thing, which is possible type mismatch
>checking, but I don't think that is significant enough to justify
>the change.

I may be sorry in the morning for asking this, but:

Isn't the latter generally preferable, given its possible use as a
parameter for a function with no prototype in scope?  Further, isn't the
former dangerous in this case, given that there is no guarantee for NULL
and (int)0 to have the same representation?



============================================================================
David Wald                                              wald-david at yale.UUCP
						       waldave at yalevm.bitnet
============================================================================



More information about the Comp.lang.c mailing list