...
Inline functions are, in general, more suitable for this task . (See see PRE00-C. Prefer inline or static functions to function-like macros). ) Occasionally, however, they are not feasible (when macros are expected to operate on variables of different types, for example).
When multiple statements are used in a macro, they should be bound together in a do-while loop syntactically, so the macro can appear safely inside if clauses or other places that expect a single statement or a statement block. (Alternatively, when an if, for, or while statement uses braces even for a single body statement, then multiple statements in a macro will expand correctly even without a do-while loop . See (see EXP19-C. Use braces for the body of an if, for, or while statement).)
Noncompliant Code Example
...
| Tool | Version | Checker | Description | ||||||
|---|---|---|---|---|---|---|---|---|---|
| LDRA tool suite |
| 79 S | Enhanced Enforcementenforcement | ||||||
| PRQA QA-C |
| 3412 | Fully implemented |
...
Search for vulnerabilities resulting from the violation of this rule on the CERT website.
Related Guidelines
...
| ISO/IEC TR 24772:2013 | Pre-processor Directives [NMP] |
...