Parenthesize all parameter names in macro definitions. See also PRE00-C. Prefer inline or static functions to function-like macros and PRE02-C. Macro replacement lists should be parenthesized.
Noncompliant Code Example
...
Code Block |
---|
#define JOIN(a, b) (a ## b) #define SHOW(a) printf(#a " = %d\n", a) |
See PRE05-C. Understand macro replacement when concatenating tokens or performing stringification for more information on using the ##
operator to concatenate tokens.
...
Tool | Version | Checker | Description | ||||||
---|---|---|---|---|---|---|---|---|---|
| 78 S | Fully implemented | |||||||
| macrbody | Fully implemented | |||||||
PRQA QA·CQA-C |
| Fully implemented |
...
ISO/IEC 9899:2011 Section 6.10, "Preprocessing directives," and section 5.1.1, "Translation environment"
ISO/IEC PDTR 24772 "JCW Operator precedence/order of evaluation"
MISRA Rule 19.1
Bibliography
[Plum 1985]
[Summit 2005] Question 10.1
...