脑筋转不过来,求真相帝回答

ljc879 2010-08-06 02:47:59
在编译VC++6.0是,出现
fatal error C1010: unexpected end of file while looking for precompiled header directive

问题详细解释:
致命错误C1010,在寻找预编译指示头文件时,文件未预期结束。就是没有找到预编译指示信息的头文件。

问题一般发生在:
通过添加文件的方式,添加了一些cpp文件到一个MFC的程序,但该cpp文件并不是MFC,是标准C++的。

解决方案1:
右键点击项目工程中的该cpp文件,在菜单Project 》Settings里C++页面的Precomplie Header,设置为第一项:Not using precompiled headers。

解决方案2:
在.cpp文件开头添加包含文件stdafx.h。

#include "stdafx.h"


为什么一定要加#include "stdafx.h"呢,不明白。加的标准c++类只是做一些计算,和MFC关系不大啊,为什么一定要加stdafx.h这个头文件,第一个解决方案又是怎么回事呢
...全文
106 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
用户 昵称 2010-08-06
  • 打赏
  • 举报
回复
硬性规定
Eleven 2010-08-06
  • 打赏
  • 举报
回复
第一个就是不是用预编译头文件
vnking 2010-08-06
  • 打赏
  • 举报
回复
我也不太明白
iamshuke 2010-08-06
  • 打赏
  • 举报
回复
按MSDN中Q119329 "AppWizard and Precompiled Header Files"中的说法:

AppWizard puts the line "#include 'stdafx.h'" as one of the first lines in every .CPP file in a project. Because of the compiler options being used by projects generated with AppWizard, anything up to and including "stdafx.h" in a .CPP file is considered by the compiler to be part of a precompiled header.

The problem with this is that when you edit the .CPP files and insert #includes, #defines, declarations, or other code before the "#include 'stdafx.h'" line, all of it is ignored by the compiler. This is the correct behavior because when the compiler is using the precompiled header, it starts to compile the code in the .CPP file after skipping past the "stdafx.h" line.

一大堆,其实意思就是说当设定编译器使用预编译头文件(比如stdafx.h)时,编译每个cpp的时候都会跳过#include "stdafx.h"之前的行,当cpp中没有该行时编译器就傻了。内部约定吧。

比如下面的代码在VC6中就能正常编译通过。

这里可以随便写, 不会编译的
lkdsfkdskfs;ew]<>-<>.
#include "stdafx.h"
junliang0824 2010-08-06
  • 打赏
  • 举报
回复
不太懂,都是一种模式,与内部什么的有关系吧,你跟着走OK了
cdsnpeter 2010-08-06
  • 打赏
  • 举报
回复
第一个方案,就是不使用预编译头文件,不使用自然没有这个问题。

16,548

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • AIGC Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧