#include <stdio.h>
#include<assert.h>
#include<iostream>
//断言:迅速找到
using namespace std;
#define N 10
void main1()
{
int num = 100;
cout << num << endl;
cout << __FILE__ << endl; //当前文件名
cout << __LINE__ << endl;// 当前行数
cout << __DATE__ << endl;
cout << __TIME__ << endl;
cout << __FUNCTION__ << endl; //当前函数
cin.get();
}
#define M //条件编译:若定义M则 进入
void main()
{
char num = 10;
//字节>4
assert(num > 12);
#ifdef M
static_assert(sizeof(num) >= 4, "yincheng error");
#endif
//调试代码,迅速代码错误在哪一行
}
静态断言
最新推荐文章于 2024-04-02 21:18:53 发布