Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rule 4-10-2 NULL is not a c++ standard
#4
minhyuk Wrote:
misra cpp Wrote: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.

according to ISO-IEC-14882(2003)
Quote:C.2.2.3 Macro NULL [diff.null]
1 The macro NULL, defined in any of , , , , ,
, or , is an implementation-defined C + + null pointer constant in this International
Standard (18.1).
According to 4.10 of the C++ standard, a null pointer constant is defined as an integer type of rvalue that is zero.
In order to use NULL, special headers must be included in the code, and 0 is defined as a null pointer constant in the C ++ standard, so I think it is more correct to use 0 rather than NULL.
If you don't want to include those headers just use a deviation permit (something like NULL is obsolete because C++11 has the far safer nulllptr keyword).
<t></t>
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)