Why NULL is 0 - summary

Richard A. O'Keefe ok at quintus.UUCP
Mon Mar 21 18:40:20 AEST 1988


This is painfully bad style, but I have often seen[*] code which did e.g.

        char x = NULL;

What was intended, of course, was something like
        #define NUL '\0'
                                /* ok for EBCDIC and ASCII both */
        char x = NUL;
but what was written was technically correct and had the intended effect.

NULL is 0, not 0L, and not (sometype*)0.  Just 0.
I don't use plain NULL for anything, always
        #define NullFoo ((Foo*)0)
        ...
        #define NullBaz ((Baz*)0)

[*] No it _wasn't_ my code!



More information about the Comp.lang.c mailing list