条件编译
#include <iostream> using namespace std; #define DEBUG #define MIN(a,b) (((a)<(b))?a:b) int main() { int i,j; i=100; j=30; //如果没有定义符号常量DEBUG,会进行编译 #ifdef DEBUG cerr<<"Trace: Inside main function"<<endl; #endif #if 0 /*注释部分 不进行编译的代码*/ cout<<MKSTR(HELLO C++)<<endl; #endif cout<<"The minimum is"<<MIN(i,j)<<endl; #ifdef DEBUG //调试时进行编译 cerr<<"Trace: coming out of main function"<<endl; #endif system("pause"); return 0; }