Module 15 · The Preprocessor, Headers and Multi File Builds
Macros: define, Function Macros and Their Traps
ProReading
Zara tests edge cases first. She wrote a MAX macro with every bracket in place, then handed it i++. With i at 5 and j at 3, she expected biggest = 5, i = 6.
Pro lesson
This one goes deeper
It is included with this track and with Learn Pro. Every question on the Skill Test can be answered from the free lessons, so this is depth and never a gate on the certificate.
What is inside Macros: define, Function Macros and Their Traps
- A macro is text the preprocessor pastes
- Trap 1: an argument without parentheses
- Trap 2: a body without outer parentheses
- Trap 3: an argument evaluated twice
- Trap 4: a macro of several statements
- A static inline function does the same job
- Two operators only macros have: # and ##
- An X-macro keeps two tables in step