Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The relevant part of the C spec:</p> <blockquote> <p>6.10.3.1 Argument substitution</p> <p>After the arguments for the invocation of a function-like macro have been identified, argument substitution takes place. A parameter in the replacement list, unless preceded by a # or ## preprocessing token or followed by a ## preprocessing token (see below), is replaced by the corresponding argument after all macros contained therein have been expanded. Before being substituted, each argument’s preprocessing tokens are completely macro replaced as if they formed the rest of the preprocessing file; no other preprocessing tokens are available.</p> </blockquote> <p>The key part that determines whether you want the double indirection or not is the second sentence and the exception in it -- if the parameter is involved in a <code>#</code> or <code>##</code> operation (such as the params in <code>mymacro</code> and <code>NAME2_HIDDEN</code>), then any other macros in the argument are NOT expanded prior to doing the <code>#</code> or <code>##</code>. If, on the other hand, there's no <code>#</code> or <code>##</code> IMMEDIATELY in the macro body (as with <code>NAME2</code>), then other macros in the parameters ARE expanded.</p> <p>So it comes down to what you want -- sometimes you want all macros expanded FIRST, and then do the <code>#</code> or <code>##</code> (in which case you want the double layer indirection) and sometime you DO NOT want the macros expanded first (in which case you CAN'T HAVE double layer macros, you need to do it directly.)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload