Why’s that inside do/while?
Consider this:
if (e)
SWAP(a, b);
else
something_else();
Currently, that expands to this, which is still valid code: if (e)
do {
// ...macro...
} while(0);
else
something_else();
If it were just wrapped in braces, the code would be parsed like this: // One-armed if-statement
if (e) {
// ...macro...
}
// Empty statement
;
// Another statement
else something_else();
It's incorrect syntax to start a statement with else, so the compiler will say something like "Unexpected 'else' at line N.""What's the best way to write a multi-statement macro?"
SWAP(…);