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 instructions will be checked at compile time.
So, if the #if condition is true, DoWork (); DoAnotherWork () will be compiled otherwise; will be compiled. Where, as in the previous example, all code including the if statement will be compiled.
Read it in the Preprocessor Directives
Preprocessor directives
source
share