Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Corrected quoted C99 section.

Wiki Markup
The arguments to a macro should not include preprocessor directives such as {{\#define}}, {{\#ifdef}}, and {{\#include}}.  Doing so is [undefined behavior|BB. Definitions#undefined behavior] according to section 6.10.3.1, paragraph 11 of the C99 standard \[[ISO/IEC 9899:1999|AA. C References#ISO/IEC 9899-1999]\]:

...


<blockquote><p>The sequence of preprocessing tokens bounded by the outside-most matching parentheses forms the list of arguments for the function-like macro.

...

&nbsp; The individual arguments within the list are separated by comma preprocessing tokens, but comma preprocessing tokens between matching inner parentheses do not separate arguments.

...

The scope of this rule includes using preprocessor directives in arguments to a function where it is unknown whether or not the function is implemented using a macro.  For example, standard library functions such as memcpy(), printf(), and assert() may be implemented as

&nbsp; <strong>If there are sequences of preprocessing tokens within the list of arguments that would otherwise act as preprocessing directives, the behavior is undefined.</strong></p></blockquote>The scope of this rule includes using preprocessor directives in arguments to a function where it is unknown whether or not the function is implemented using a macro.&nbsp;  For example, standard library functions such as {{memcpy()}}, {{printf()}}, and {{assert()}} may be implemented as macros.

Noncompliant Code Example

...

Wiki Markup
\[[GCC Bugs|http://gcc.gnu.org/bugs.html#nonbugs_c]\] "Non-bugs"
\[[ISO/IEC 9899:1999|AA. C References#ISO/IEC 9899-1999]\] Section 6.10.3.111, "MacroArgument replacement"substitution," paragraph 11