pointers, tests, casts

Daniel E. Wilson danw at tekchips.CRL.TEK.COM
Thu Dec 1 08:36:12 AEST 1988


In article <494 at auspex.UUCP>, guy at auspex.UUCP (Guy Harris) writes:
> >In assignments, a 0 or NULL is cast implicitly to the correct pointer
> >type (I think, please correct me if I'm wrong).
> 
> This is correct.
> 
> >What about the '==' comparison above?  Would "(ptr == 0)" get evaluated
> >correctly?

  I tend to avoid the whole problem by defining a simple macro.  Simply
by using this macro always I get a NULL pointer of the needed type.
This does avoid bugs.

     #define NIL(type) ((type *) NULL)

  Unless someone would like to give me warnings about the abuses
of macros. 8-)



More information about the Comp.lang.c mailing list