I see alot of code thats written like this
Usually this is done to hide some extra feature, debug code or platform code. It can be nicer to just branch off the preprocessor instead.
That way the compiler will always evaluate both paths so if a particular branch goes stale you’ll know about it sooner.
Compile with something,
Compile without something,
There is no performance impact, the compiler is smart enough to notice the branch is constant and throw away the other branch.
Two things to consider however
- Its not allways possible as sometimes are trying to hide platform differences.
- MSVS will generate a warning by default.