fatal error C1010: unexpected end of file while looking for precompiled header directive
为什么会出现这个错误

解决方案 »

  1.   

    1、极有可能是少加了一条包含命令:#include "stdafx.h";
    2、点击菜单Build-->BuildAll,重新编译一遍即可;
    3、如果以上都不是,那么检查一下是否包含的文件有错误。
      

  2.   

    By default, Visual C++ projects use precompiled headers. This is a system whereby the large Windows headers are compiled only once when you build stdafx.cpp. Every other .CPP file in your project needs to #include "stdafx.h" as the first #include in order to build. The compiler specifically looks for the name "stdafx.h" to know when to insert the precompiled header information.If you received the source for an entire program from someone else, and you want to build it as a Visual C++ project, you can turn off precompiled headers instead. In your project options, go to the C/C++ tab and select the Precompiled headers category. Click the Not using precompiled headers radio button, then click OK.what's a precompiled header? After the headers included by stdafx.cpp are processed, the preprocessor saves a snapshot of its internal state, which includes all the function prototypes and #defines in the Windows headers, along with anything else you added to stdafx.h. This snapshot is saved in a .PCH file. Since processing all those headers takes a long time, when the compiler compiles the other .CPP files, it reloads the preprocessor state from the .PCH file instead of processing all the headers again.The preprocessor looks for an #include "stdafx.h" line or a #pragma hdrstop directive to tell when it should read the .PCH file. If neither of those lines is present, you'll get error C1010.
      

  3.   

    谢谢两位
    我已添加了:#include "stdafx.h",也不行
    产生错误的文件是由我自已设计的类(不是由ClassWizard产生的)
    类才写一点点,括号都有对应,我将出错的文件(.cpp)的全部内容删掉,
    还是会出现这个错误!
      

  4.   

    把CPP的内容都写完,再试试。
      

  5.   

    你在哪个位置是用了自己的类,把它删除试试,我在使用拆分视图时如果视图使用mfc自动生成的文档-视图类就会出现这个问题