The C preprocessor is an early translation phase that replaces identifiers and function-like macro calls with token sequences before compilation. Replacement follows rules specified by the C standard, producing the same intermediate source for compilers on the same platform. section 17.1 section 18.1.3
A function-like macro expands textually
Given #define BYTECOPY(T, S) memcpy(&(T), &(S), MINSIZE(T, S)), an invocation such as BYTECOPY(redA, B) expands its arguments, substitutes them into the replacement text, and recursively expands macros appearing there. The resulting text can become memcpy(&(redA), &(B), (sizeof((redA))<sizeof((B))?sizeof((redA)):sizeof((B)))). section 17.1
Function-like macro expansion applies several constraints:
- Temporarily disables the macro during its expansion to prevent infinite recursion. section 17.1
- Scans parentheses and commas to divide the argument list; unmatched parentheses and incorrect argument counts violate the invocation rules. section 17.1
- Requires parameters to be identifiers and limits their special scope to the replacement text. section 17.1
- Supports type-generic expressions, declarations, definitions, and statement-like groups, but statement macros can involve ugliness and maintenance costs. section 18.1.3
#define BYTECOPY(T, S) memcpy(&(T), &(S), MINSIZE(T, S))
Inspect the BYTECOPY definition to see how address-taking, nested macros, and a computed size combine in one replacement sequence. section 17.1


