AUTOSAR C++14 Rule M16-0-5
Arguments to a function-like macro shall not contain tokens that look like pre-processing directives
Description
Rule Definition
Arguments to a function-like macro shall not contain tokens that look like pre-processing directives.
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® reports a violation if an argument of a function like macro contains a
preprocessor conditional directive, i.e. an #if..#else..#endif
block.
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, Automated |