21 lines
735 B
Plaintext
21 lines
735 B
Plaintext
In programming languages keywords have a special meaning and are reserved to the language. It is hence a bad idea to define macros with keywords as macro identifier as it can easily lead to undefined behavior:
|
||
|
||
* The same object might be defined differently in different places, which violates the One Definition Rule
|
||
* If you include any header from the standard library, it is undefined behavior to define such macros
|
||
|
||
Additionally, it is very awkward for anyone reading the code to have a keyword that means something different.
|
||
|
||
|
||
== Noncompliant Code Example
|
||
|
||
----
|
||
#define int some_other_type // Noncompliant
|
||
#include <stdlib.h>;
|
||
----
|
||
|
||
|
||
== See
|
||
|
||
* MISRA C:2012, 20.4 - A macro shall not be defined with the same name as a keyword
|
||
|