Why is this an issue?
The standard, predefined macros, such as __FILE__
and __LINE__
, are primarily intended for use by the implementation, and
changing them could result in undefined behavior.
This rule checks that the following predefined macros are not defined, undefined, or redefined: assert
, errno
,
__FILE__
, __LINE__
, __TIME__
, __DATE__
, __TIMESTAMP__
, __COUNTER__
,
__INCLUDE_LEVEL__
, __BASE_FILE__
, and _Pragma
.
Noncompliant code example
#undef __LINE__
Resources
- MISRA C:2004, 20.1 - Reserved identifiers, macros and functions in the standard library shall not be defined, redefined, or undefined
- MISRA C++:2008, 17-0-1 - Reserved identifiers, macros and functions in the standard library shall not be defined, redefined, or undefined
- MISRA C:2012, 21.1 - #define and #undef shall not be used on a reserved identifier or reserved macro name