I have compared gcc assembler output of
do {
// some code
} while (0);
with
do {
// some code
break;
} while (1);
The output is equal, with or without optimization but..
It's always that way?
No experiment can prove theories, they can only show they are wrong
There is a slight difference:
do {
// code
if ( condition )
continue;
// code
break;
} while(1);
Will restart the loop when condition is true, whereas in the } while(0); version, the continue will be equivalent to break.
If no continue is present, then they should produce exactly the same code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With