Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

PRE01-EX2: Macro parameters cannot be individually parenthesized when concatenating tokens using the ## operator, converting macro parameters to strings using the # operator, or concatenating adjacent string literals. The JOIN() macro below concatenates both arguments to form a new token. The SHOW() macro converts the single argument into a string literal, which is then concatenated with the adjacent string literal to form the format specification in the call to printf()passed as a parameter to printf(), as a string and as a parameter to the %d specifier.  For example, if SHOW() is invoked as SHOW(66);, the macro would be expanded to printf("66" " = %d\n", 66);.

Code Block
#define JOIN(a, b) (a ## b)
#define SHOW(a) printf(#a " = %d\n", a)

...

CERT C++ Secure Coding StandardPRE01-CPP. Use parentheses within macros around parameter names
ISO/IEC TR 24772Operator precedence/order of evaluation [JCW] and Pre-processor Directives [NMP]
MISRA-C

Rule 19.1 (advisory): #include statements in a file should only be preceded by other preprocessor directives or comments

...