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.
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 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.
I think you missed the whole point of my comment 😂. Regardless, the time spent compiling a small snippet of code is completely negligible. In the end, both and
if (false)
have their complimentary uses.