TITLE: definition of NULL (Newsgroups: comp.lang.c++.moderated) PROBLEM: shappir@libra.math.tau.ac.il (Shappir Dan) I've encountered several differences between GNU C++ (ver 2.7.2) and Watcom C++ (ver 10.0) and I wonder which is correct: 1. Watcom C++ defines NULL as 0 (or 0L) while GNU C++ defines NULL as ((void*)0). RESPONSE: clamage@Eng.Sun.COM (Steve Clamage), 2 Jul 96 The draft standard requires NULL to be a null pointer constant. A null pointer constant is "an integral constant expression rvalue of integer type that evaluates to zero". 0 and 0L are therefore valid, but ((void*)0) is not valid. The point of NULL is that you can write things like char* p = NULL; which will not work in C++ if NULL has type void*. In C, ((void*)0) is the preferred definition, because a void* can be converted implicitly to other pointer types. Not so in C++. NULL is still defined to be a macro for compatibility with C. It is required to be a macro in C, and if C++ changed the requirement it would break existing code like "#ifdef NULL".