On NULL and 0
Dave Korn
dave.korn@artimi.com
Tue Mar 13 13:56:00 GMT 2007
On 13 March 2007 13:52, Paulo J. Matos wrote:
> Hello,
>
> When programming, due to my journeys through C++ recently, I've been
> using 0 instead of NULL. Strangely gcc compilation doesn't warn me
> about it. Is it ok to do this? (So far, I had no problems). Is there
> anything I should be aware when using 0 instead of NULL in gcc code?
Nope. (This is really a gcc-help@ question, but anyway....) Zero is
completely acceptable for a null pointer constant in all circumstances
*except* when passing to a varargs function, which can go badly wrong on
platforms where the sizeof a pointer is larger than the sizeof an int. See
the gnu coding standards, which mentions this.
cheers,
DaveK
--
Can't think of a witty .sigline today....
More information about the Gcc
mailing list