#error的用法

  • #error用于生成一个编译错误消息

    • 用法:error message(不需要用双引号包围)
  • #error编译指示字用于自定义程序员特有的编译错误,消息类似的
  • #warning用于生成编译警告
  • #error是一种预编译器指示字
  • #error可用于提示编译条件是否满足

编译过程中的任意错误信息意味着无法生成最终的可执行程序

例子1:#error预处理初探

#include<stdio.h>

#ifndef __cplusplus
#error This file should be processed with c++ compliler.
#endif // __cplusplus class CppClass
{
private:
int m_value;
public:
CppClass(){}
~CppClass(){}
}; int main()
{
return 0;
}

#line的用法

#line用于强制制定新的行号和编译文件名,并对源程序的代码重新编号

用法:#line number filename(filename可以省略)

#line编译指示字的本质是重定义 LINE__和__FILE

#include <stdio.h>    

int main()
{
printf("%s : %d\n", __FILE__, __LINE__); #line 1 "change.c" printf("%s : %d\n", __FILE__, __LINE__); return 0;
}

小结

  • #error用于自定义一条编译错误信息
  • #warning用于自定义一条编译警告信息
  • #error和#warning常用于条件编译的情形
  • #line用于强制指定新的行号和编译文件名

#error和#line使用分析的更多相关文章

  1. 第23课 - #error 和 #line 使用分析

    第23课 - #error 和 #line 使用分析 1. #error 的用法 (1)#error 是一个预处理器指示字,用于生成一个编译错误消息,这个消息最终会传递到编译器(gcc) 在思考这一点 ...

  2. 第23课 #error和#line使用分析

    #error的用法: 示例程序: #include <stdio.h> #ifndef __cplusplus #error This file should be processed w ...

  3. Error on line -1 of document : Premature end of file. Nested exception: Premature end of file.

    启动tomcat, 出现, ( 之前都是好好的... ) [lk ] ERROR [08-12 15:10:02] [main] org.springframework.web.context.Con ...

  4. 关于xml加载提示: Error on line 1 of document : 前言中不允许有内容

    我是在java中做的相关测试, 首先粘贴下报错: 读取xml配置文件:xmls\property.xml org.dom4j.DocumentException: Error on line 1 of ...

  5. (转载)Flash Loader加载完成不发送COMPLETE和ERROR事件的问题分析

    (转载)http://blog.dou.li/flash-loader%E5%8A%A0%E8%BD%BD%E5%AE%8C%E6%88%90%E4%B8%8D%E5%8F%91%E9%80%81co ...

  6. error on line 1 at column 6: XML declaration allowed only at the start of the document

    This page contains the following errors: error on line 1 at column 6: XML declaration allowed only a ...

  7. "fatal: protocol error: bad line length character: No This"

    git clone 远程地址时候出现 "fatal: protocol error: bad line length character: No This" 错误 在stackov ...

  8. Parse Fatal Error at line 41 column 24: 元素类型 "url-pattern" 必须由匹配的结束标记 "</url-pattern>" 终止

    1.错误描述 严重: Parse Fatal Error at line 41 column 24: 元素类型 "url-pattern" 必须由匹配的结束标记 "< ...

  9. (转)Windows 平台下解决httpd.exe: syntax error on line 39

    近来在研究PHP,结果为了Apache的安装伤神不已...小白我在安装后,启动Apache的服务虽然可以,不过,在Apache sevice monitor 中启动services时就会出现如下的问题 ...

随机推荐

  1. gnss到底是什么呢

    GNSS Global Navigation Satellite System 全球卫星导航系统:提到这个很多人会不明白GNSS倒是是个啥东西呢,和北斗,GPS, GLONASS,Galileo系统有 ...

  2. SDUT OJ 周赛 找有毒的那杯水(思维逻辑 + 分治思想 )

    你打我啊 Time Limit: 500ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 最近看了一个非常好玩的题,如果有972杯水,其中有971个没有毒的,1个有 ...

  3. HUST - 1010 The Minimum Length(最小循环节)

    1.赤裸裸的最小循环节 2. 3. #include<iostream> #include<stdio.h> #include<string.h> using na ...

  4. 基于jQuery仿淘宝产品图片放大镜特效

    在开发商城的时候,往往会用到图片的放大功能,这里把自己在近期项目中使用的放大镜特效做一下总结(非插件). 放大镜效果 常用的js组件jquery.imagezoom,jquery.jqzoom,jqu ...

  5. BZOJ_4278_[ONTAK2015]Tasowanie_后缀数组

    BZOJ_4278_[ONTAK2015]Tasowanie_后缀数组 Description 给定两个数字串A和B,通过将A和B进行二路归并得到一个新的数字串T,请找到字典序最小的T. Input ...

  6. BZOJ_4276_[ONTAK2015]Bajtman i Okrągły Robin_线段树优化建图+最大费用最大流

    BZOJ_4276_[ONTAK2015]Bajtman i Okrągły Robin_线段树优化建图+最大费用最大流 Description 有n个强盗,其中第i个强盗会在[a[i],a[i]+1 ...

  7. 「LuoguP3381」【模板】最小费用最大流

    Description 如题,给出一个网络图,以及其源点和汇点,每条边已知其最大流量和单位流量费用,求出其网络最大流和在最大流情况下的最小费用. Input 第一行包含四个正整数N.M.S.T,分别表 ...

  8. IOS 的调试模式

    iOS调试模式分为: 断点单步调试: 全局断点调试: 僵尸调试: 暴力调试: 这里主要说一下什么是僵尸调试模式? .为什么会使用NSZombieEnabled? 应用调试可能会收到类似 Thread ...

  9. UI:KVO、KVC

    什么是KVC 什么是 KVO ? KVC:(NSKey ValueCoding)”键-值  编码“是一种间接的访问对象属性(字符串表征)的机制.对象的属性都可以通过使用KVC机制用相同的方式访问.我们 ...

  10. virtualBox更改虚拟机内存大小

    在cmd中进入到virtualbox安装目录 查看目前的虚拟机列表: VBoxManage list vms 读取虚拟机具体信息 VBoxManage showvminfo <uuid>| ...