Error Message
unexpected end of file while looking for precompiled header. Did you forget to add '#include name' to your source?
http://msdn.microsoft.com/en-us/library/d7fz9ckx(VS.80).aspx 写道
Error Message
unexpected end of file while looking for precompiled header. Did you forget to add '#include name' to your source?
An include file specified with /Yu is not listed in the source file. This option is enabled by default in most Visual C++ Project types and "stdafx.h" is the default include file specified by this option.
In the Visual Studio environment, use one of the following methods to resolve this error:
If you do not use precompiled headers in your project, set the Create/Use Precompiled Header property of source files to Not Using Precompiled Headers. To set this compiler option, follow these steps:
*In the Solution Explorer pane of the project, right-click the project name, and then click Properties.
*In the left pane, click the C/C++ folder.
*Click the Precompiled Headers node.
*In the right pane, click Create/Use Precompiled Header, and then click Not Using Precompiled Headers.
Make sure you have not inadvertently deleted, renamed or removed header file (by default, stdafx.h) from the current project. This file also needs to be included before any other code in your source files using #include "stdafx.h". (This header file is specified as Create/Use PCH Through File project property)
两种解决方法:
工程上点击右键,选择property->c/c++->precompiled headers,选择not using precompiled headers即可。
或者加上 #include "stdafx.h"
stdafx.h
名称的英文全称为:Standard Application Framework Extensions
所谓头文件预编译,就是把一个工程(Project)中使用的一些MFC标准头文件(如Windows.H、Afxwin.H)预先编译,以后该工程编译时,不再编译这部分头文件,仅仅使用预编译的结果。这样可以加快编译速度,节省时间。
预编译头文件通过编译stdafx.cpp生成,以工程名命名,由于预编译的头文件的后缀是“pch”,所以编译结果文件是projectname.pch。(如果设置了not using precompiled headers那么工程的debug目录下就没有.pch文件。)
因此,所有的MFC实现文件第一条语句都是:#include "stdafx.h"。

http://baike.baidu.com/view/1344257.htm 写道
通俗一点说:
当我们使用AppWizard来自动生成某些项目的时候,系统会自动把所需要include的头文件在stdafx.h中先include一下,这样,我们只需要直接include这个stdafx.h文件即可.因为同一个项目中的不同源文件CPP都包含相同的include文件,这样,为每个.CPP文件都重复include这些文件就显得很傻了。当然如果你不用MFC的话就不用了。即:在每个.cpp文件中都include stdafx.h 就相当于包含了其他的如iostream.h等文件.

- 大小: 96.5 KB
分享到:
相关推荐
在编程过程中,尤其是在使用Microsoft Visual Studio (VC) 进行C++开发时,可能会遇到一个编译错误:“fatal error C1010: unexpected end of file while looking for precompiled header directive”。这个错误通常...
* fatal error C1010:unexpected end of file while looking for precompiled header directive。解决方法:检查是否缺少#include "stdafx.h"语句。 * fatal error C1083:Cannot open include file: 'R…….h': No ...
1. Fatal Error C1010:unexpected end of file while looking for precompiled header directive 这是一个常见的编译错误,原因是编译器在寻找预编译头文件时遇到了不该遇到的文件尾。解决方法是包含正确路径的#...
- **fatal error C1010: unexpected end of file while looking for precompiled header directive** - 确保每个文件都正确包含了预编译头文件。 - **fatal error C1083: Cannot open include file: 'R.h': No such...
1、fatal error C1010: unexpected end of file while looking for precompiled header directive。 此错误通常是由于没有#include "stdafx.h"引起的,即找不到预编译头文件的路径。 2、fatal error C1083: Cannot...
fatal error C1010: unexpected end of file while looking for precompiled header directive 这个错误是在寻找预编译头文件路径时遇到了不该遇到的文件尾。解决方法是:其一,即可含正确路径的#include "stdafx.h...
1. fatal error C1010: unexpected end of file while looking for precompiled header(寻找预编译头文件时意外遇到文件结束),解决方法是确保#include "stdafx.h"正确包含在*.cpp文件中,并在设置中确保预编译...
6. "fatal error C1010: unexpected end of file while looking for precompiled header directive":这通常发生在尝试预编译头文件时,但文件结尾不正确。检查是否完整复制了头文件。 7. "fatal error C1083: ...
一、fatal error C1010: unexpected end of file while looking for precompiled header directive 这是因为没有包含预编译头文件“stdafx.h”,导致编译器无法找到预编译头文件。解决方法是添加#include "stdafx.h...
fatal error C1010: unexpected end of file while looking for precompiled header directive. ``` **原因:** 此错误通常发生在未包含预编译头文件(如`stdafx.h`)的情况下。预编译头文件通常用于加速编译过程,...
**错误信息**:fatal error C1010: unexpected end of file while looking for precompiled header directive **解释**:在寻找预编译头文件指令时,意外地遇到了文件末尾。通常这意味着在应该包含预编译头文件...
1. fatal error C1010: unexpected end of file while looking for precompiled header directive 这是编译错误之一,出现该错误的原因是预编译头文件路径不正确。解决方法是将正确路径的#include "stdafx.h"添加到...
fatal error C1010: unexpected end of file while looking for precompiled header directive **描述**:此错误发生在预编译头文件(如`stdafx.h`)未正确包含的情况下。 **解决方案**: - 确保在项目设置中正确...
1. **fatal error C1010: unexpected end of file while looking for precompiled header directive**:这通常意味着在预编译头文件(如`stdafx.h`)应该存在的地方没有找到它。解决方案是在项目设置中确保启用了预...
1. fatal error C1010: unexpected end of file while looking for precompiled header directive 这是一种致命错误,发生在编译器查找预编译头文件时遇到了文件尾,通常是因为缺少#include "stdafx.h"语句。解决...
- 同时,还提到了一些问题处理,例如编译错误(如:fatal error C1010: unexpected end of file while looking for precompiled header directive)的解决方法,以及在VC++工程中配置相应的.dll和.lib文件。...
在某些情况下,如果不改变预编译头文件设置,编译时可能会遇到错误:“fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your ...
fatal error C1010: unexpected end of file while looking for precompiled header directive 此错误通常出现在编译器试图在源代码文件中查找预编译头文件(Precompiled Header, PCH)指令时遇到文件结束的情况。...
fatal error C1010: unexpected end of file while looking for precompiled header directive 当VC++在寻找预编译头文件路径时遇到了文件结束标志,即表示在源代码中预编译头文件的包含指令(`#include "stdafx.h"`...