测试代码:
#include <iostream> int main() { bool bFlag = false; if (bFlag) { std::cout << "This statement will never be executed. " << std::endl; #pragma message("The if statements will be compiled, whether the expression is true or false.") #define PI 3.14 } // PI is defined, as the macro PI is compiled previous. std::cout << "PI = " << PI << std::endl; return 0; }
编译结果:
1>------ Build started: Project: Win32ConsoleApp, Configuration: Debug Win32 ------ 1>Compiling... 1>Win32ConsoleApp.cpp 1>The if statements will be compiled, whether the expression is true or false. 1>Build log was saved at "file://e:/VS2008/Exercise_VS2008/Win32ConsoleApp/Debug/BuildLog.htm" 1>Win32ConsoleApp - 0 error(s), 0 warning(s) ========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
执行结果:
PI = 3.14 Press any key to continue . . .