210-pp-arg-prescan.c (624B)
1 /* Per C11 ยง6.10.3.1: function-like macro arguments must be 2 * macro-expanded BEFORE substitution into the body, except when 3 * the parameter is the operand of `#` or `##`. 4 * 5 * `M(M(1))` for `#define M(x) ((x) + (x))`: 6 * With prescan: inner M(1) -> ((1) + (1)); outer expands to 7 * ((((1) + (1))) + (((1) + (1)))) = 4. 8 * Without prescan: outer body becomes ((M(1)) + (M(1))) where M 9 * is in every substituted token's hide-set, so the inner Ms 10 * never expand and the parser sees calls to undeclared `M`. 11 */ 12 13 #define M(x) ((x) + (x)) 14 15 int main(void) { 16 int v = M(M(1)); 17 return v == 4 ? 0 : 1; 18 }