If the expressions inside these IFs are constant and defined at compile time , you can be pretty sure that the compiler has already removed them from the code for you.
Of course, if you compile in Debug-Mode and / or if you have an optimization level of zero, then the compiler can skip this and leave these tests, but with equal values โโzero / one / true / false is unlikely.
For compile-time constant branches, you can be sure that the compiler has deleted the dead.
It can even remove complex windows, for example:
const int x = 5; if( 3 * x * x < 10 )
However, without this 'const' token in X, the value of the expression may not be determined at compile time, and it may โleakโ into the actual final product.
In addition, the value of the expression in the following code is not necessarily a compile-time constant:
const int x = aFunction(); if( 3 * x * x < 10 )
X is a constant, but it is initialized with the value from the function. X will most likely not be detected at compile time. At run time, the function can return any value *), so the compiler should assume that X is unknown.
Therefore, if you have the opportunity, use a preprocessor. In trivial cases that will not do much, because the compiler already knew about it. But cases are not always trivial, and you will often notice a change in vrey. When the optimizer does not output a value, it leaves the code, even if it is dead. The preprocessor, on the other hand, ensures that deleted partitions are deleted before they are compiled and optimized. In addition, using a preprocessor for this will at least speed up compilation: the compiler / optimizer will not have to trace constants / calculations / checkbranches, etc.
*) you can write a method / function, the return value can actually be determined at the compilation and optimization stages: if the function is simple and if it is embedded, its result can be optimized along with some branches .. But even if you can rely to some extent on removing if-0 sentences, you cannot rely on inlining as much.