Versions Compared

Key

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

...

Non-Compliant Code Example

Wiki MarkupThe following definition for {{static_assert()}} from \[[DCL03-A. Use a static assertion to test the value of a constant expression]] uses the {{JOIN()}} macro to concatenate the token {{assertion_failed_at_line_}} with the value of {{\_\_LINE\_\_}}.

Code Block
#define static_assert(e) \
  typedef char JOIN(assertion_failed_at_line_, __LINE__) [(e) ? 1 : -1]

...

JOIN(x, y) calls JOIN_AGAIN(x, y) so that, if x or y is a macro, they are expanded before the ## operator pastes them together.

Wiki MarkupNote 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]\].

Non-Compliant Code Example

...