You are viewing a single thread.
View all comments
61 points

Very disappointing not to see an #if 0 (my personal go-to for decades) in this meme. 😞

permalink
report
reply
25 points

Damn, you beat me to it.

It’s common enough that it’s supported like a comment by numerous syntax highlighting schemes, and has the added benefits of guaranteeing that the code won’t be compiled as well as encapsulating any pre-existing block comments. Conversely, if (false) is total garbage.

permalink
report
parent
reply
14 points

If (false) is good because it is compiled so it doesn’t get stale.

permalink
report
parent
reply
6 points

“you’re not wrong, you’re just an asshole”

permalink
report
parent
reply

A simple if (false) will get optimized out by any modern C or C++ compiler with optimizations on, but the problem is that the compiler will still parse and spend time on what’s inside the if-block and it has to be legal code, whereas with the #if 0 trick the whole thing gets yeeted away by the preprocessor before even the compiler gets to look at it regardless of whether that block contains errors or not.

permalink
report
parent
reply
2 points

Tell this to my -Wall -Werror

permalink
report
parent
reply

beat me to it too, it’s a meme of course but the advantage compared to comments is thay you get syntax highlighting 😁

permalink
report
parent
reply
2 points

My linter always skips preprocessors not set to build, in c# at least, greys it all out unfortunately

permalink
report
parent
reply
2 points

this is what I’m doing too, so at least it’s not compiled and better than a /* */ as you can keep all the code intact in your #if 0

permalink
report
parent
reply

Programmer Humor

!programmerhumor@lemmy.ml

Create post

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

  • Posts must be relevant to programming, programmers, or computer science.
  • No NSFW content.
  • Jokes must be in good taste. No hate speech, bigotry, etc.

Community stats

  • 6.8K

    Monthly active users

  • 1.4K

    Posts

  • 32K

    Comments