[Development] 0 vs. NULL

Thiago Macieira thiago.macieira at intel.com
Thu Oct 8 17:07:40 CEST 2015


On Thursday 08 October 2015 13:01:50 René J.V. Bertin wrote:
> > and I'm not entirely sure about NULL, for that matter (it might just
> > expand to 0, at least in C, but perhaps not in C++).
> 
> Given how NULL is usally defined as ((void*)0) or equivalent, there should
> not be any issues in that aspect.

It's NOT defined as that in C++. The C++ standard is very clear about that.

18.1 (C++98) / 18.2 (current) [lib.support.types] says:

"The macro NULL is an implementation-defined C++ null pointer constant in this 
International Standard(180)"

And the note reads

"180)Possible definitions include 0 and 0L, but not (void*)0."

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center




More information about the Development mailing list