4 ms·
Multi-line macros should be wrapped in “do { ... } while (0)” anyway. Not only does it ensure that control flow constructs apply to them atomically as intended,
by pwdisswordfish2 7y ago
Multi-line macros should be wrapped in “do { ... } while (0)” anyway. Not only does it ensure that control flow constructs apply to them atomically as intended, regardless if they use curly brackets or not, but also isolates any potential variable declarations into their own scope, ensures that all uses of the macro are followed by a semicolon and gives you an early exit construct for free (“break;”).