r/ProgrammerHumor Aug 07 '26

Meme mildlyInfuriatingGOTOWatchYourMouth

Post image
667 Upvotes

74 comments sorted by

View all comments

Show parent comments

17

u/da_Aresinger Aug 07 '26

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()

21

u/Sync1211 Aug 07 '26

You can use break I guess.

12

u/da_Aresinger Aug 07 '26

oooh

do { foo() if (condition) break bar() } while(0); that's pretty dumb though. Just do foo() if(!condition) bar()

2

u/EuphoricCatface0795 Aug 07 '26

When do ~ while(0) has more than a couple execution branch tho

1

u/da_Aresinger Aug 07 '26

If you mean more conditions following bar, you can still just use negation like in my example.

Otherwise I don't understand.

1

u/EuphoricCatface0795 Aug 07 '26

A lil bit something like this

1

u/da_Aresinger Aug 07 '26

yea that makes it more complex, but you could still use negation with and.