if (p) ... (a clarification)

Guy Harris guy at sun.uucp
Mon Nov 11 09:07:29 AEST 1985


> >The definition of the C language requires that NULL be ZERO (how many times
> >do people have to be told this?).  ...
> 
> ...my memory tells me that 0 should convert to the NULL pointer, not
> necessarily be it.

True, but NULL isn't the null pointer any more than 0 is; NULL is just an
alternate way of saying "0".  Think of it as a comment; it doesn't tell the
compiler anything, but it tells the human reader of the code something.
NULL must be #defined to be 0 in a correct C implementation.  Null pointers
need not have the same bit pattern as 0 or 0L.
 
> ...this issue has been DISCUSSED TO DEATH n times already.  Please do
> not respond.
 
AMEN.  There is only *ONE* correct response to the question "does the
definition of the C language require that a null pointer have the same bit
pattern as the integral value 0"; the answer is NO.  If anybody disagrees,
go back and read K&R and/or Harbison and Steele until you see why there is
no reason for the answer to be YES; please don't waste your time, our time,
and all the readership's time arguing the point.

        Guy Harris



More information about the Comp.lang.c mailing list