One obvious possibility would be to use the preprocessor:
#if MY_VER
Function2();
#endif
Less obvious (but usually equally effective) is to just turn on the optimizer. What you have there is dead code, which most compilers can identify and remove quite effectively.