A macro invocation is a function-like macro name followed by parentheses containing arguments, such as BYTECOPY(A, B). The preprocessor parses balanced parentheses, uses top-level commas to separate arguments, and checks that their number matches the macro parameters. section 17.1
Expansion proceeds in a defined sequence:
- Disable the macro temporarily to prevent infinite recursive expansion. section 17.1
- Recursively expand macros appearing inside each argument. section 17.1
- Substitute the resulting argument text into a copy of the replacement text, then rescan that text for further macro replacement. section 17.1
Expanding BYTECOPY
With #define BYTECOPY(T, S) memcpy(&(T), &(S), MINSIZE(T, S)), an invocation such as BYTECOPY(A, B) expands its arguments, substitutes them into the replacement text, and expands nested MINSIZE calls. A macro invocation can also generate declarations or statement-like code, as in declareColor(color8); or a do ... while(false) wrapper. section 17.1 section 18.1.3
#define BYTECOPY(T, S) memcpy(&(T), &(S), MINSIZE(T, S))
Inspect the BYTECOPY definition to connect invocation syntax with parameter substitution and generated library-call text. section 17.1
