MISRA C++:2023 Rule 19.3.5
Tokens that look like a preprocessing directive shall not occur within a macro argument
Since R2024b
Description
Rule Definition
Tokens that look like a preprocessing directive shall not occur within a macro argument.
Rationale
When a compiler encounters function-like macros, it replaces the argument of the macro into the replacement code. If the argument contains a token that looks like preprocessing directives, the replacement process during macro expansion is undefined. Depending on the environment, such a function-like macro might behave in unexpected ways, leading to errors and bugs.
Polyspace Implementation
Polyspace® flags calls to function-like macros if their argument starts with the
character #
.
Troubleshooting
If you expect a rule violation but Polyspace does not report it, see Diagnose Why Coding Standard Violations Do Not Appear as Expected.
Examples
Check Information
Group: Preprocessing Directives |
Category: Required |
Version History
Introduced in R2024b