C语言#error

C语言#error 首页 / C语言入门教程 / C语言#error

#error预处理程序指令指示错误。如果找到#error指令,编译器将给出致命错误,并跳过进一步的编译过程。

C#错误示例

让我们看一个使用#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

祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)

教程推荐

讲好故事 -〔涵柏〕

容量保障核心技术与实战 -〔吴骏龙〕

爆款文案修炼手册 -〔乐剑峰〕

互联网人的英语私教课 -〔陈亦峰〕

数据中台实战课 -〔郭忆〕

分布式协议与算法实战 -〔韩健〕

深入浅出计算机组成原理 -〔徐文浩〕

白话法律42讲 -〔周甲徳〕

邱岳的产品手记 -〔邱岳〕

好记忆不如烂笔头。留下您的足迹吧 :)