gcc and NULL function pointers.

Roger Miller r_miller at apollo.hp.com
Tue Jun 25 00:54:34 AEST 1991


>   The issue is that #defining NULL as ((void*)0) does NOT detect such
>   misuse, nor does it adequately compensate for it in all cases.

Another reason you might prefer plain 0 to (void*)0 is that C++ does not
allow implicit casts from void* to other pointer types.  So if NULL is
defined as (void*)0 you can't write "int *p = NULL".  This is of course
irrelvant in a pure C or pure C++ environment, but C++ programmers often
want to share C header files, and I have seen this lead to
    #ifdef NULL
    #undef NULL
    #define NULL my-way
battles in the source code.



More information about the Comp.std.c mailing list