Python Preprocessor Macros & Storage Classes
The C preprocessor expands macros (#define) and includes headers before compilation. Storage classes dictate variable lifetime and visibility: static preserves state across function calls and limits file visibility, while extern shares global symbols across translation units.
"A static local variable is a tally counter on a kitchen fridge: every time someone enters the room and clicks it, the number keeps going up and never resets to 0."
Deep Dive: How It Works
Parameterized Macros: Literal textual replacement; always parenthesize parameters (((a) > (b)) ? (a) : (b)).
Header Guards: #ifndef / #define / #endif prevents duplicate type definitions in multiple inclusions.
static Lifetime: Keeps local variable state alive across repeated function invocations.
Syntax Blueprint
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
void count(void) {
static int n = 0;
n++;
}Define safe parameterized macro and static variable that persists across calls.
Core Rules to Remember



Common Beginner Traps & How to Fix Them
Macro side effects: #define SQR(x) ((x) * (x)) called with SQR(i++).Why it happens: i++ is expanded twice, causing unintended double increments.
How to fix: Avoid passing expressions with side effects (like i++) into preprocessor macros.
Live Interactive Example
Hit Run Code to see it liveYour Turn: Micro Challenge
No pressure! Edit the starter code below and test your solution with instant feedback.
Demonstrate Third Static Call
Invoke trackCounter() a 3rd time to demonstrate static variable persistence.
Finished reading and practicing?
Mark this lesson as completed to update your course progress.