pointers, tests, casts

Doug Gwyn gwyn at smoke.BRL.MIL
Tue Dec 6 03:07:54 AEST 1988


In article <44803 at yale-celray.yale.UUCP> wald-david at CS.YALE.EDU (david wald) writes:
>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?

There's also no guarantee that (void *) and other pointer types have the
same representation.  You MUST cast NULL when using it as a function
argument with no prototype in scope.  (If it happens to work without a
cast, it's an accident.  Your program should not rely on accidents to
work correctly.)



More information about the Comp.lang.c mailing list