Re: ?? warning: ANSI C++ forbids implicit conversion from `void * ' in initialization ???



>The C/C++ standards define NULL such that the onus is left to the
>implementation to define NULL as something that "works".

That may be true. However, the C++ standard, such as it is, is quite
specific about what it means to assign an integral value of zero to a
pointer lvalue, or when testing a pointer value against an integer
value of zero.

This is precisely why many C++ programmers, myself included, prefer to
use 0 rather than NULL. NULL may or may not be the right thing,
whereas 0 almost certainly is.

>Therefore, unless you plan on stating that "our tools only work on
>'sensible' systems", for your own definition of sensible, "NULL" actually
>is more portable than "0". (perhaps not by very much at all... 

Its the other way around. The standards do not pin down a definition
of NULL because there is no standard definition that can be guaranteed
to work. Thus, using 0 is actually much more portable because its
operation/semantics are defined by the standard. Actually, as Joseph
pointed out here yesterday, even 0 has problems for cases where there
is an overloaded function with both pointer and integer variants.

>								but is it
>really worth fighting over?)

No. Just worth getting right.

--p



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]