As the title states, I was wondering what are the differences between using
#if
DoWork();
#else
DoAnotherWork();
#endif
and
if (debug)
DoWork();
else
DoAnotherWork();
if (debug)
DoWork();
else
DoAnotherWork();
The above code will be compiled and the condition will be checked at runtime.
#if
DoWork();
#else
DoAnotherWork();
#endif
These statements will be checked at compile time.
So if #if condition is true, DoWork(); will be compiled and otherwise DoAnotherWork(); will be compiled. Where as in the previous example all code including the if statement will be compiled.
Please read this on Preprocessor Directives
Preprocessor Directives
First is Preprocessor Directive and second Logical statement.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With