Parenthesize all parameter names in macro definitions. See also guidelines PRE00-C. Prefer inline or static functions to function-like macros and PRE02-C. Macro replacement lists should be parenthesized.
...
Code Block |
---|
#define JOIN(a, b) (a ## b) #define SHOW(a) printf(#a " = %d\n", a) |
See guideline PRE05-C. Understand macro replacement when concatenating tokens or performing stringification for more information on using the ##
operator to concatenate tokens.
...
Recommendation | Severity | Likelihood | Remediation Cost | Priority | Level |
---|---|---|---|---|---|
PRE01-C | medium | probable | low | P12 | L1 |
Automated Detection
...
Tool | Version | Checker | Description |
---|---|---|---|
|
...
|
|
|
Related Vulnerabilities
Search for vulnerabilities resulting from the violation of this rule on the CERT website.
Other Languages
Related Guidelines
This rule appears in the C++ Secure Coding Standard as : PRE01-CPP. Use parentheses within macros around parameter names.
Bibliography
Wiki Markup |
---|
\[[ISO/IEC 9899:1999|AA. Bibliography#ISO/IEC 9899-1999]\] Section 6.10, "Preprocessing directives," and Section 5.1.1, "Translation environment" \[[ISO/IEC PDTR 24772|AA. Bibliography#ISO/IEC PDTR 24772]\] "JCW Operator precedence/Order of Evaluation" \[[MISRA 042004|AA. Bibliography#MISRA 04]\] Rule 19.1 \[[Plum 851985|AA. Bibliography#Plum 85]\] \[[Summit 052005|AA. Bibliography#Summit 05]\] Question 10.1 |
...