C++? when did that happen?
tim at ngus.net
Sat Oct 8 08:30:05 PDT 2005
On Sat, 8 Oct 2005 03:45:35 +0200 Ludwig wrote:
> Tim Angus wrote:
> > [...]
> > I'll say again, using 0 in place of NULL in C is perfectly valid and
> > correct. Yes, NULL is implementation defined, but that DOES NOT make
> > the use of 0 in place of NULL wrong, nor does it make it a "C++ism".
> You cannot blindly replace NULL with 0. sizeof(0) != sizeof(NULL) on
> 64bit platforms. Variadic functions for example will break if you pass
> 0 where you wanted to pass NULL. So always use NULL if you refer to a
In the general case though, if you have a function:
void function( something *p );
...and you call it...
function( 0 );
...what the compiler actually emits is...
function( (something *)0 ); // where sizeof( 0 ) is the appropriate word
The sizeof 0 doesn't matter since 0 is really being used as a contextual
token to denote a null pointer, not an actual value.
I'm not suggesting that every NULL be replaced with 0. When writing C, I
use NULL to initialise pointers. My point is that it is OK to use 0
instead of NULL in the general case, and especially in this case.
More information about the ioquake3