Parenthesize all parameter names in macro definitions. See also guidelines recommendations 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 recommendation PRE05-C. Understand macro replacement when concatenating tokens or performing stringification for more information on using the ##
operator to concatenate tokens.
...
Search for vulnerabilities resulting from the violation of this rule on the CERT website.
Related Guidelines
CERT C++ Secure Coding Standard: PRE01-CPP. Use parentheses within macros around parameter names
Bibliography
unmigrated-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 Rule 19.1
Bibliography
Wiki Markup |
---|
\[[MISRA 2004|AA. Bibliography#MISRA 04]\] Rule 19.1
\[[Plum 1985|AA. Bibliography#Plum 85]\]
\[[Summit 2005|AA. Bibliography#Summit 05]\] Question 10.1 |
...