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.
Checking what this lesson needs for you…
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