MISRA C:2023 Rule 21.1
#define and #undef shall not be used on a reserved identifier or reserved macro name
Since R2024a
Description
Rule Definition
#define and #undef shall not be used on a reserved identifier or reserved macro name.
Rationale
Reserved identifiers and reserved macro names are intended for use by the implementation. Removing or changing the meaning of a reserved macro can result in undefined behavior. This rule applies to the following:
Identifiers or macro names beginning with an underscore
Identifiers in file scope described in the C Standard Library
Macro names described in the C Standard Library as being defined in a standard header
The rule checker can flag different identifiers or macros depending on the version
of the C standard used in the analysis. See C standard version
(-c-version)
. For instance, if you run a C99
analysis, the reserved identifiers and macros are defined in the ISO®/IEC 9899:1999 standard, Section 7, "Library".
Troubleshooting
If you expect a rule violation but do not see it, refer to Diagnose Why Coding Standard Violations Do Not Appear as Expected.
Examples
Check Information
Group: Standard Libraries |
Category: Required |
AGC Category: Required |
Version History
Introduced in R2024a