Macros and the C preprocessor

Macros

Macros

Not separate, code is replaced before it is run

#define PI 3.14

These are then expanded before compiling.

Parametised macros

We can also replace using functions.

For example we could do:

print(3 + 1)
print(2 + 1)

or

#define plusOne(x) (x+1)
print(plusOne(x))
print(plusOne(x))