8/11/2018 - 1:39 PM

macro definition

Simplest use of macro definition is to define a constant

#define EXIT_SUCCESS 0

#define SQUARE(x) x * x
but be careful. Because what happens if we attempt SQUARE(z-y)?
If this were a function, we would evaluate z-y to a value and copy it into 
the stack frame for a call to SQUARE, however, this is a macro expansion, 
so the preprocessor works only with text. It expands the macro by replacing x in
the macro definition with the text z-y, resulting in z-y * z-y. Note that this 
will compute z- (y*z) -y, which is not z-y squared.
#define SQUARE(x) ((x) * (x))