guber@lemmy.blahaj.zone to Lemmy Shitpost@lemmy.world · 5 months agoproportional reactionlemmy.blahaj.zoneimagemessage-square15linkfedilinkarrow-up11arrow-down10
arrow-up11arrow-down1imageproportional reactionlemmy.blahaj.zoneguber@lemmy.blahaj.zone to Lemmy Shitpost@lemmy.world · 5 months agomessage-square15linkfedilink
minus-squaregroctel@lemmy.worldlinkfedilinkarrow-up0·5 months agoAt my previous workplace we had a C macro that was something like #define CheckWhatever(x__, true__, false__) \ whatever(x) ? (true__) : (false__) I don’t remember this shit, so I’m just paraphrasing cursed C. The question one would ask is… why? Well, because you also want to do #define CheckWhatever2(x__, true__, false__) \ CheckWhatever((x__ ##1), (true__), (false__)) \ CheckWhatever((x__ ##2), (true__), (false__)) And, of course #define CheckWhatever3(x__, true__, false__) \ CheckWhatever2((x__ ##1), (true__), (false__)) \ CheckWhatever2((x__ ##2), (true__), (false__)) Long story short, someone wanted to CheckWhatever6 inside another macro. While debugging code old enough to vote, my editor suggested expanding the macro, which expanded to ~1400 lines for a single ternary operator chain. Fun times!
minus-squareguber@lemmy.blahaj.zoneOPlinkfedilinkarrow-up0·5 months agoyeah… yikes. c is a beautiful language but thing like these are why macros may be it’s largest blemish. hope that codebase doesn’t keep planes flying!
At my previous workplace we had a C macro that was something like
#define CheckWhatever(x__, true__, false__) \ whatever(x) ? (true__) : (false__)I don’t remember this shit, so I’m just paraphrasing cursed C. The question one would ask is… why? Well, because you also want to do
#define CheckWhatever2(x__, true__, false__) \ CheckWhatever((x__ ##1), (true__), (false__)) \ CheckWhatever((x__ ##2), (true__), (false__))And, of course
#define CheckWhatever3(x__, true__, false__) \ CheckWhatever2((x__ ##1), (true__), (false__)) \ CheckWhatever2((x__ ##2), (true__), (false__))Long story short, someone wanted to
CheckWhatever6inside another macro. While debugging code old enough to vote, my editor suggested expanding the macro, which expanded to ~1400 lines for a single ternary operator chain. Fun times!yeah… yikes. c is a beautiful language but thing like these are why macros may be it’s largest blemish. hope that codebase doesn’t keep planes flying!
I have bad news for you