VC++6.0编译时出现fatal error C1010: unexpected end of file while looking for precompiled header directiv

来源:互联网 发布:广州锐博生物知乎 编辑:程序博客网 时间:2024/05/22 15:43

在编译VC++6.0是,出现fatal error C1010: unexpected end of file while looking for precompiled header directive 
的错误.

解决方法:

1、如果发生错误的文件是由其他的C代码文件添加进入当前工程而引起的,则Alt+F7进入当前工程的 Settings,选择C/C++选项卡,从Category组合框中选中Precompiled Headers,选择Not Using Precompiled headers。确定。

2、在文件开头添加: (其他Include之前),此时确认Settings->C/C++->Category->Precompiled Headers,设置为第四个选项Using Precompiled headers
#include "stdafx.h"

  对预编译头文件说明如下:   
    
  所谓头文件预编译,就是把一个工程(Project)中使用的一些MFC标准头文件(如Windows.H、Afxwin.H)预先编译,以后该工程编译时,不再编译这部分头文件,仅仅使用预编译的结果。这样可以加快编译速度,节省时间。   
    
  预编译头文件通过编译stdafx.cpp生成,以工程名命名,由于预编译的头文件的后缀是“pch”,所以编译结果文件是projectname.pch。   
    
  编译器通过一个头文件stdafx.h来使用预编译头文件。stdafx.h这个头文件名是可以在project的编译设置里指定的。编译器认为,所有在指令#include   "stdafx.h"前的代码都是预编译的,它跳过#include   "stdafx.   h"指令,使用projectname.pch编译这条指令之后的所有代码。   
    
  因此,所有的CPP实现文件第一条语句都是:#include   "stdafx.h"。


注意:最好不要重新写stdafx.h 以及 stdafx.cpp 文件,而在实现中并没有包含真正的include"stdafx.h",则可能出现c:\users\administrator\desktop\ccallcppdemo\stdafx.cpp(9) : error C2857: '#include' statement specified with the /Ycstdafx.h command-line option was not found in the source file
执行 cl.exe 时出错.   即使使用上述解决方法一,也不能解决这个问题,我暂时解决方法时:要么就不要重写stdafx的源文件和头文件;要么就在重写的源文件和头文件中加入include"stdafx.h"

0 0