Better to use parentheses in the macro so that the macro can be used "normally". You wouldn't normally have to bracket a subexpression so requiring the programmer to remember for SQR that they have to do
will lead to bugs because you don't remember stuff like this.
So define the macro as
#define SQR(x) ( (x) * (x) )
so that it can be used normally, i.e.
The brackets around the individual x's mean you can put subexpressions into SQR. Without them, the second would be substituted as:
Of course you always have to be very careful with side effect operators. This won't have the expected result:
What's i? 16? Nope. No amount of bracketing will fix this, which is why we make macros upper case. And relying on this is definitely a bad idea, cos if some smart alec rewrites SQR as
#define SQR(x) (pow((x),2))
then i will be 16 and not 17 as you expected.