Parameterized Macros
#define SQR(x) ((x)*(x))
After this definition, the preprocessor replaces every occurrence of the form
SQR(a)
by the replacement text
((a)*(a))
For example:
w = SQR(x) + 1;
z = SQR(w+1);
becomes
w = ((x)*(x)) + 1;
z = ((w+1)*(w+1));
Previous slide
Next slide
Back to first slide
View graphic version