(整理中)异常处理笔记

一、#ifdef debug …#endif

本语句可在函数之外使用,也可在函数之内使用
函数外之间填写预处理语句与定义类等等函数外的语句
函数内之间填写函数内使用的语句

#include<stdio.h>

#define PI 5

#define print(x) puts("hello\n"#x);

int main()
{
    
    
    #ifdef PI
    puts("#$");
    #endif // debug

	print(#$%^@#%@#$%@#%@#%@#%);
	printf("%d",PI);
}

结果为

#$
hello
#$%^@#%@#$%@#%@#%@#%
5

二、#error

如果运行到此句,终止程序编译,并在报告中显示error原因(原因需自己写)
在这里插入图片描述

由于软件的不同
vs在被证明会用到此语句时,直接将#error标红,不需要编译
qt在编译时才会在报告中显示error

猜你喜欢

转载自blog.csdn.net/qq_36769966/article/details/105454965