CCoding Style - Parenthesize the macro body and arguments
Parenthesize the macro body and arguments
Macros work by textual substitution: the parameters in the definition are replaced by the arguments of the call and the result replaces the original call, as text. This is a troublesome difference from function.
#define Square(x) ( x * x )
And invoked as
The expression will be expanded to ( z+1*z+1)
#define Square(x) ( (x) * (x) )