tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: definition of NULL correct?

> Why not, given that "sizeof 10" works, and NULL is ultimately
> supposed to be just another constant expression?

For the same reason that "sizeof (float)(2+3)", or "sizeof (int)10" (to
tweak your exmaple) doesn't work, even though (float)(2+3) and (int)10
are just as much "just another constant expression".

> Unless there's a specific escape hatch for null pointer constants, it
> ought to at least be syntactically valid.

I don't see why.  Plenty of expressions - mostly involving casts -
become syntax errors when you tack a "sizeof" on in front of them.  I
don't see anything prohibiting "NULL" from being another.

Yet another reason to avoid NULL, is my stake on it.

> Whether the value it generates is useful is a different matter... :-)

Yeah.  The only use I've been able to think of for it is to allow
probing whether the local system uses the integer option or the
pointer-to-void option for NULL on systems where they have different

Since this does not help with systems where they have the same size,
and since it's not clear that this is an important thing to be able to
detect anyway (especially since I believe NULL should never be used), I
have trouble caring about this supposed problem in a pragmatic sense.

/~\ The ASCII                             Mouse
\ / Ribbon Campaign
 X  Against HTML      
/ \ Email!           7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B

Home | Main Index | Thread Index | Old Index