: in defining NULL to be 0 rather than (void*) 0. NULL must be a
: constant integral expression that evaluates to 0; "0" satisfies
: that requirement, and "(void*) 0" does not.
Question 5.6 from the comp.lang.c FAQ
5.6: If NULL were defined as follows:
#define NULL ((char *)0)
wouldn't that make function calls which pass an uncast NULL
A: Not in general. The problem is that there are machines which
use different internal representations for pointers to different
types of data. The suggested definition would make uncast NULL
arguments to functions expecting pointers to characters work
correctly, but pointer arguments of other types would still be
problematical, and legal constructions such as
FILE *fp = NULL;
Nevertheless, ANSI C allows the alternate definition
#define NULL ((void *)0)
for NULL. Besides potentially helping incorrect programs to
work (but only on machines with homogeneous pointers, thus
questionably valid assistance), this definition may catch
programs which use NULL incorrectly (e.g. when the ASCII NUL
character was really intended; see question 5.9).
References: Rationale Sec. 4.1.5.
The answer to question 5.9 includes the following text:
NULL should *not* be used when another kind of 0 is required,
even though it might work, because doing so sends the wrong
stylistic message. (Furthermore, ANSI allows the definition of
NULL to be ((void *)0), which will not work at all in non-
pointer contexts.) In particular, do not use NULL when the
ASCII null character (NUL) is desired. Provide your own
#define NUL '\0'
if you must.