error C1010: 在查找预编译头时遇到意外的文件结尾。是否忘记了向源中添加“#include "stdafx.h”
来源:互联网 发布:邮件软件中文字体 编辑:程序博客网 时间:2024/05/21 19:23
fatal error C1010: 在查找预编译头时遇到意外的文件结尾。是否忘记了向源中添加“#include "stdafx.h
(2011-09-08 22:17:50)错误描述:fatal error C1010: 在查找预编译头时遇到意外的文件结尾。是否忘记了向源中添加“#include "stdafx.h"”?
一、概念:
1、预编译:就是编译器首先编译某个文件(称为预编译头文件),然后将这个编译结果保存起来,之后如果有其他源文件include了这个“预编译头文件”的时候,则自动从这个编译结果提取需要的信息进行编译。
2、预编译结果文件(Precompiled header file):就是那个用来保存已经编译了的符号信息的文件(.PCH作为后缀)
3、生成预编译结果文件(Create Precompiled header file):我们说源文件A通过文件B“生成预编译结果文件”是指编译A的时候将其中编译B的编译结果保存成预编译结果文件。一般使用向导的话,A文件就是“stdafx.cpp”,B文件是“stdafx.h”。stdafx.cpp中就一行语句:
#include “stdafx.h”
4、使用预编译头(Using precompiled header):我们说某个源文件(a.cpp)通过“stdafx.h”来使用预编译结果是指编译a.cpp的时候,如果a.cpp第一行include语句是#include “stdafx.h”的话,那么直接取预编译结果文件的结果,不再重新编译”stdafx.h”
二、向导是怎么做的?
1、设置“stdafx.cpp”的预编译选项是通过“stdafx.h”文件来“生成预编译结果文件”。
2、其他源文件的预编译选项设置是通过“stdafx.h”来“使用预编译头”
三、使用原则?
1、将相对稳定的头文件(比如CRT,STL,第三方固定的库)全部写在stdafx.h中。(是否使用stdafx.h依赖个人喜好,不过使用stdafx.h可以和向导保持一致)
2、全部源文件第一行都加#include “stdafx.h”。
3、一些不能修改的源文件(如果公共的代码,不具备权限修改的代码),设置他的预编译选项是“不使用预编译头”。注意,一定不能是选择“自动生成预编译头”,因为这样会将stdafx.h的结果冲掉(这个不知道是BUG还是设计的问题了,.^_^。)。
四、Q&A
Q、为什么不全部使用“自动生成预编译头文件”?
A、“自动生成预编译头文件”和什么都不用没有什么两样,编译速度没有质的提高。
Q、手工添加一个新的源文件到项目的时候,经常出现类似错误:
fatal error C1010: unexpected end of file while looking for precompiled header directive
A、因为向导缺省的设置是“使用预编译头”,但是你新加的文件并没有在第一行包含“stdafx.h”。解决的方法要么修改成“不使用预编译头”,要么添加一行#include “stdafx.h”
Q、加stdafx.h和stdafx.cpp总觉得是和编译平台绑定了,不具备移植性?
A、其实,注意一下stdafx.h的写法就没有问题了。我的解决方案是(stdafx.h的内容):
–begin of file stdafx.h
#ifdef _WIN32
#include “win.h”
#else
#include “linux.h”
#endif
#include “crt.h”
#include
–end of file
或者更加简单一点,如果不是VC编译器,那么stdafx.h就什么内容都不写!
- VC中的预编译:fatal error C1010: 在查找预编译头时遇到意外的文件结尾。是否忘记了向源中添加“#include "stdafx.h"”?
- fatal error C1010 error c2143 warning C4627: 在查找预编译头时遇到意外的文件结尾。是否忘记了向源中添加“#include "stdafx.h
- vc编程中出现 fatal error C1010: 在查找预编译头时遇到意外的文件结尾。是否忘记了向源中添加“#include "stdafx.h"”?
- fatal error C1010: 在查找预编译头时遇到意外的文件结尾。是否忘记了向源中添加“#include "stdafx.h
- fatal error C1010: 在查找预编译头时遇到意外的文件结尾。是否忘记了向源中添加“#include "stdafx.h"?
- fatal error C1010: 在查找预编译头时遇到意外的文件结尾。是否忘记了向源中添加“#include "stdafx.h
- fatal error C1010: 在查找预编译头时遇到意外的文件结尾。是否忘记了向源中添加“#include "stdafx.h
- vs2010:fatal error C1010: 在查找预编译头时遇到意外的文件结尾。是否忘记了向源中添加“#include "StdAfx.h"”?
- 错误描述:fatal error C1010:在查找预编译头时遇到意外的文件结尾。是否忘记了向源中添加“#include"stdafx.h"”?
- fatal error C1010: 在查找预编译头时遇到意外的文件结尾。是否忘记了向源中添加“#include "stdafx.h
- 错误描述:fatal error C1010: 在查找预编译头时遇到意外的文件结尾。是否忘记了向源中添加“#include "stdafx.h"”?
- fatal error C1010: 在查找预编译头时遇到意外的文件结尾。是否忘记了向源中添加“#include "stdafx.h
- fatal error C1010: 在查找预编译头时遇到意外的文件结尾。是否忘记了向源中添加“#include "stdafx.h
- 错误描述:fatal error C1010:在查找预编译头时遇到意外的文件结尾。是否忘记了向源中添加“#include"stdafx.h"”?
- fatal error C1010: 在查找预编译头时遇到意外的文件结尾。是否忘记了向源中添加“#include "stdafx.h
- fatal error C1010: 在查找预编译头时遇到意外的文件结尾。是否忘记了向源中添加“#include "stdafx.h
- vs2010:fatal error C1010: 在查找预编译头时遇到意外的文件结尾。是否忘记了向源中添加“#include "StdAfx.h"”?
- vs2010:fatal error C1010: 在查找预编译头时遇到意外的文件结尾。是否忘记了向源中添加“#include "StdAfx.h"”?
- sort -u和uniq区别
- WPF--火车后台管理系统分析(一)
- 最直白理解NFC开发的三种工作模式
- 使用spring中的JdbcTemplate调用oracle中的有出入参数的存储过程
- Python(2) import .py文件
- error C1010: 在查找预编译头时遇到意外的文件结尾。是否忘记了向源中添加“#include "stdafx.h”
- 经典冒泡排序法,传引用参数的那种,面试通用
- 【栈 && 矩阵的知识】UVA 442 Matrix Chain Multiplication
- Caffe+windows7+Visual Studio 2015+Python+CPU配置记录
- 条件对象(条件变量)——线程学习六
- BZOJ3295: [Cqoi2011]动态逆序对
- Eloquent JavaScript 笔记 七: Electronic Life
- MYSQLl防注入
- ubuntu安装配置hadoop伪分布式及eclipse搭建hadoop环境