Versions Compared

Key

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

...

When the parameter names are surrounded by commas in the replacement text, regardless of how complicated the actual arguments are, there is no need for parenthesizing the macro parameters. Since commas have lower precedence than any other operator, there is no chance of the actual arguments being parsed in a surprising way.

No Formatcode
 #define FOO(a, b, c) bar(a, b, c)
/* ... */
FOO(arg1, arg2, arg3);

When token pasting or stringization is performed, the arguments must not be parenthesized individually.

Code Block

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

Risk Assessment

Failing to parenthesize the parameter names in a macro can result in unintended program behavior.

...