C1020: 意外的 #endif
2015-06-18 11:07
387 查看
对于“ fatal error C1020: 意外的 #endif ”错误,原因大致如下:
如果使用了预编译头,VC会在所有CPP文件里寻找
#include "stdafx.h "
在找到这行代码之前,VC会忽略所有代码。
也就是说,下例中,VC 找到第二行 #include "stdafx.h" 之前,会将第一行#ifndef _EiC 忽略掉,因此出现“意外的 #endif”找不到匹配。
#ifndef _EiC
#include "stdafx.h"
#include "cv.h"
#include "cxcore.h"
#include "highgui.h"
#endif
将上例修改为如下所示即可。
#include "stdafx.h"
#ifndef _EiC
#include "cv.h"
#include "cxcore.h"
#include "highgui.h"
#endif
PS. :#ifndef V.S. #ifdef
#ifndef避免编译时多个相同头文件的重复编译及避免冲突。
PPS. :
所有的CPP实现文件第一条语句都是:#include "stdafx.h"
因为编译器认为,所有在指令#include "stdafx.h"前的代码都是预编译的,它跳过#include "stdafx. h"指令,使用projectname.pch编译这条指令之后的所有代码。
转自:http://blog.csdn.net/zhmyy/article/details/5331984
如果使用了预编译头,VC会在所有CPP文件里寻找
#include "stdafx.h "
在找到这行代码之前,VC会忽略所有代码。
也就是说,下例中,VC 找到第二行 #include "stdafx.h" 之前,会将第一行#ifndef _EiC 忽略掉,因此出现“意外的 #endif”找不到匹配。
#ifndef _EiC
#include "stdafx.h"
#include "cv.h"
#include "cxcore.h"
#include "highgui.h"
#endif
将上例修改为如下所示即可。
#include "stdafx.h"
#ifndef _EiC
#include "cv.h"
#include "cxcore.h"
#include "highgui.h"
#endif
PS. :#ifndef V.S. #ifdef
#ifndef避免编译时多个相同头文件的重复编译及避免冲突。
PPS. :
所有的CPP实现文件第一条语句都是:#include "stdafx.h"
因为编译器认为,所有在指令#include "stdafx.h"前的代码都是预编译的,它跳过#include "stdafx. h"指令,使用projectname.pch编译这条指令之后的所有代码。
转自:http://blog.csdn.net/zhmyy/article/details/5331984
相关文章推荐
- sublime 无敌神key 注册码 破解版
- 查询表与之相关联的子表
- linux下 安装mysql数据库
- 时刻保持联网 微软计划推全球WiFi服务
- hdu 4109 Instrction Arrangement (topo+关键路径) (附简单的测试数据)
- android 布局学习---线性布局
- 往Xcode中拖入图片,否则模拟器启动时找不到
- opencv学习笔记6:轮廓
- C++运算符重载为成员函数
- 斯派克程序数据库设计
- DHCP和NAT的概念与对比
- 更改ubuntu 默认终端程序为terminator
- CaaS
- SAT阅读素材:a learning sysstem
- Hibernate实体映射
- android view类的settag gettag就是在类中加了一个类似id的字段?
- C++中++运算符的重载
- [html5]placeholder默认颜色
- 代码大全读后感(3)
- 团队项目第一次冲刺(2)