#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 {}
}
}
3、把变量和表达式转换成字符串 可是使用字符串运算符来实现转换输出定义 #define PR(x) cout<<#x”=”<<x<<'/n'
4、c语言的assert() 该宏在中,,当使用assert时候,给他个参数,即一个判读为真的表达式。预处理器产生测试该断言的代码,假如断言不为真,则发出一个错误信息告诉断言是什么以及它失败一会,程序会终止。
#include< assert>
using namsapce std;
int main()
{
int i=100;
assert(i!=100);
//Fails
}
当调试完毕后在#include<assert>前新闻热点
疑难解答