#error预处理程序指令指示错误。如果找到#error指令,编译器将给出致命错误,并跳过进一步的编译过程。
让我们看一个使用#error预处理指令的简单示例。
#include <stdio.h>#ifndef __MATH_H #error First include then compile #else void main(){ float a; a=sqrt(7); printf("%f",a); } #endif
输出:
链接:https://www.learnfk.comhttps://www.learnfk.com/c-programming/c-preprocessor-error.html
来源:LearnFk无涯教程网
Compile Time Error: First include then compile
但是,如果包含math.h,则不会给出错误。
#include <stdio.h>#include <math.h> #ifndef __MATH_H #error First include then compile #else void main(){ float a; a=sqrt(7); printf("%f",a); } #endif
输出:
链接:https://www.learnfk.comhttps://www.learnfk.com/c-programming/c-preprocessor-error.html
来源:LearnFk无涯教程网
2.645751
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)