Versions Compared

Key

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

...

Token pasting is most useful when one or both of the tokens comes from a macro argument. If either of the tokens next to an ## is a parameter name, it is replaced by its actual argument before ## executes. The actual argument is not macro - expanded first.

Stringification

...

Note also that 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. This is an exception PRE01-EX2 to PRE01-A. Use parentheses within macros around parameter names.

...

The macro invocation xstr(foo) expands to "4". This is because 's' is stringified when it is used in str(), so it is not macro - expanded first. However, 's' is an ordinary argument to xstr(), so it is completely macro - expanded before xstr() is expanded. Consequently, by the time str() gets to its argument, it has already been macro - expanded.

Risk Assessment

Recommendation

Severity

Likelihood

Remediation Cost

Priority

Level

PRE05-A

low

unlikely

medium

P2

L3

...