This is to cope with macro shortcomings - they are just a text replacement!
imagine the following macro
#define DOUBLE(x) x*2
int v = DOUBLE(1+1); // == 1+1*2 == 3. Did you expect 4?
So the rules of thumb for macros are:
- use them only if there's no other way to solve your problem
- wrap every parameter in parantheses (to avoid above problem)
- wrap the entire expression in parantheses (to avoid other, similar problems)
- make every parameter only occur once (to avoid problems with side effects)
So, a better macro would be:
#define DOUBLE(x) ((x)*2)
You are almost there, the remaining parantheses in you example are due to the cast.
So we can criticise two points:
Q: why is it a macro, not an inline function?
A: Backward compatibility. C doesn't have inline functions (or at least didn't), using functions for the probably thousands of such declarations would have brought down most compilers of that time.
Q: Are the parantheses really required for this specific macro?
A: I don't know. It would probably take me half an hour or more to formally proof (or disproof) there is no sensible parameter and "call" environment where this has unintended effects. I'd rather follow sensible guidelines as mentioned above, and go on coding.