3 ms·
You can put it inside a braceless if/else statement and follow it with a semicolon. Compare: #define FOO() { ... } #define BAR() do { ... } while (0) In
by LegionMammal978 4y ago
You can put it inside a braceless if/else statement and follow it with a semicolon.
Compare:
#define FOO() { ... }
#define BAR() do { ... } while (0)
In the former case:
if (x)
FOO();
else
...;
// becomes
if (x) {
...
}
;
else
...;
In the latter case:
if (x)
BAR();
else
...;
// becomes
if (x)
do {
...
} while (0);
else
...;