#define DEBUG #ifdef DEBUG 调试代码 #endif
#include<iostream> #include <string> using namespace std; bool debug =false; int main(int argc,char*argv[]) { for(int i=0;i<argc;i++) if(string(argv[i])==“--debug=on“) debug = true; bool go=true; while(go) { if(debug) { 调试代码 }else {} } }
#define PR(x) cout<<#x”=”<<x<<'\n'
#include< assert> using namsapce std; int main() { int i=100; assert(i!=100); //Fails } 当调试完毕后在#include<assert>前 加入#define NDEBUG即可消除红产生的代码 }