On Jan 7, 2012, at 11:39 AM, Tomaz Canabrava wrote:
Stroustrup answer to that:
Should I use NULL or 0?
In C++, the definition of NULL is 0, so there is only an aesthetic difference. I prefer to avoid macros, so I use 0. Another problem with NULL is that people sometimes mistakenly believe that it is different from 0 and/or not an integer.
Actually, for a modern compiler NULL is not an integer.
C++ did a bit of a change, and 0 gained special meaning. I believe that most of the systems where it made an actual difference are now gone, but it did.
However... the main reason I made the code change is that when I updated to gcc 4.5.2, it started warning on that constructor. It complained that we were setting a pointer value into a non-pointer variable.
So we probably have NULL defined as some pointerish macro or value and which should not be assigned to integer variables, while '0' is a magical constant that the compiler knows to just do the right thing with for both pointers and integers. '0' by the C++ language definition works in all cases, but NULL does not.
This and the associated warning start to become very important for 64-bit code. Mixing integers and pointers leads to major problems.
Bottom line, though, is that we need to remove warnings by fixing the code. The pointer assignments in that initializer could be changed to "NULL", but the integer ones need to stay changed to zero.