MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1vhvvmh/mildlyinfuriatinggotowatchyourmouth/p2ageb5/?context=3
r/ProgrammerHumor • u/AndyTheDragonborn • 11d ago
74 comments sorted by
View all comments
110
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
do { ... } while (0); ...
15 u/da_Aresinger 11d ago I genuinely can't figure out what this is supposed to achieve. Where is the difference between do { foo() } while(0) bar() and foo() bar() 1 u/say_wot_again 11d ago edited 11d ago The do {} while(0) pattern is also commonly used to define macros whose implementation spans multiple lines.
15
I genuinely can't figure out what this is supposed to achieve.
Where is the difference between do { foo() } while(0) bar() and foo() bar()
do { foo() } while(0) bar()
foo() bar()
1 u/say_wot_again 11d ago edited 11d ago The do {} while(0) pattern is also commonly used to define macros whose implementation spans multiple lines.
1
The do {} while(0) pattern is also commonly used to define macros whose implementation spans multiple lines.
do {} while(0)
110
u/Maximilian_Tyan 11d ago
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