Posts: 5
Threads: 3
Joined: Feb 2013
Reputation:
0
In C++ Standard, There are not exist NULL(its C standard).
So, Programmer should to know about this and Use constant 0 instead of NULL macro.
<t></t>
Posts: 252
Threads: 1
Joined: Jun 2008
Reputation:
6
NULL is defined in C++ (see 4.10 of the Language Reference Manual).
Note that 4-10-2 does not ban the use of the token "NULL", but it does prohibit the use of literal "0" as a null pointer.
Posted by and on behalf of
the MISRA C++ Working Group
Posts: 252
Threads: 1
Joined: Jun 2008
Reputation:
6
Whilst agreeing with dg1980, an alternative approach if you know you do not want to include any of the C headers that include the NULL definition is to add the #define NULL 0 declaration yourself (making any required deviations necessary for use of #define other than as a guard)
The aim is to try and make it clear to the programmer (and particularly any subsequent maintainers) the difference between a value that is a pointer and an integer, hence not allowing pointer = 0;
Posted by and on behalf of
the MISRA C++ Working Group