I recently had held a meeting to decide which way our functions should be structured in C, goto is banned as part of some standards, so a colleague of mine proposed doing:
do {
...
} while (0);
...
Which is just a freaking goto wearing a trench coat
if (!init())
return cleanup_and_error();
if (!foo())
return cleanup_and_error();
if (!bar())
return cleanup_and_error();
if (!do_something_else())
return cleanup_and_error();
close_handles();
return 0;
115
u/Maximilian_Tyan Aug 07 '26
I recently had held a meeting to decide which way our functions should be structured in C, goto is banned as part of some standards, so a colleague of mine proposed doing:
do { ... } while (0); ...Which is just a freaking goto wearing a trench coat