Fatal Error C1010:unexpected end of file while looking for precompiled header

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"。

 


Fatal Error C1010:unexpected end of file while looking for precompiled header_第1张图片

 

 

 

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等文件.
 

 

 

 

你可能感兴趣的:(C++,c,C#,Microsoft,mfc)