I thought I'd be clever and write a little preprocessor wrapper around Disable/Enable interrupts, like this:
#define WITH_INTERRUPTS_DISABLED(_body) \
do { \
uint32_t primask = DisableGlobalIRQ(); \
do { \
_body \
} while (0); \
EnableGlobalIRQ(primask); \
} while (0)
The GCC preprocessor, when presented with this source:
WITH_INTERRUPTS_DISABLED(
i += 2;
quux();
);
... generates this output (reformatted for readability):
do {
uint32_t primask = DisableGlobalIRQ();
do {
i += 2;
quux();
} while (0);
EnableGlobalIRQ(primask);
} while (0)
According to Mr. Godbolt, all of the GCC variants behave as above, omitting the closing semicolon. At the same time, the output of all of clang variants INCLUDE the semicolon.
Is there a way to convince GCC to include the semicolon?