Abandon NULL for (0)

Dave Jones djones at megatest.UUCP
Sat Sep 23 07:00:47 AEST 1989


>From article <14718 at bfmny0.UU.NET>, by tneff at bfmny0.UU.NET (Tom Neff):
> In article <6502 at ux.cs.man.ac.uk> ian at ux.cs.man.ac.uk (Ian Cottam) writes:
>> I propose that the integral constant expression (0) be used instead of
>> NULL.
> 
> However (0) is not explicitly cast to a pointer type, as NULL may be
> presumed to be when appropriate.

Presume all you want, but that won't cast it. I cut this directly
out of Sun-3's stdio.h:

#define NULL    0

It's the same in BSD-4.2.  NULL is turned into 0 by the preprocessor
before the compiler proper ever sees it. NULL is an SLM (silly little
macro) that means 0.

This topic comes up in this group every now and then. After all the arguing
is over -- and it can take months -- the survivers come to the conclusion
that NULL is a mistake, but it's too late to correct it. Just say,
(FILE*)0, or (char*)0, or whatever.



More information about the Comp.lang.c mailing list