# and ## in macros

An occurrence of a parameter in a function-like macro, unless it is the operand of # or ##, is expanded before substituting it and rescanning the whole for further expansion. Because g‘s parameter is the operand of #, the argument is not expanded but instead immediately stringified ("f(1,2)"). Because h‘s parameter is not the operand of # nor ##, the argument is first expanded (12), then substituted (g(12)), then rescanning and further expansion occurs ("12").

Leave a Comment