错误信息如下:fatal error C1010: unexpected end of file while looking for precompiled header directive

解决方案 »

  1.   

    class CMyObj
    {
    };
    ^^^
    加一个分号
      

  2.   

    编译环境是什么?如果是VC++的话,在#include "obj.h"前加
    #include "stdafx.h"
    当然你需要肯定你有 "stdafx.h"
      

  3.   

    是否如下:
    LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
    Debug/obj.exe : fatal error LNK1120: 1 unresolved externals
    乃是指缺少main 函数,
    加上:
    int main()
    {
    CMyObj myobj;
    myobj.GetMyInt();
    return 0;
    }
    如果还有错误,请务必提供error message.
      

  4.   

    TO karma:
      按照你的方法,加上了stdafx.h就可以了,但素,原理是什么呢?为什么一定要加stdafx.h?
      

  5.   

    选择菜单项Project Setting,在左边选中obj.cpp,右边选择c/c++标签,其中有一个下拉框,里面选择Precompiled Headers,接着选择No using precompiled headers,再编译试试
      

  6.   

    好象使用了stdafx.h,可以生成pch文件,以后在编译的时候,可以减少编译时间。
    知道的也就这么多了。
      

  7.   

    在VC里头可以用INSERT CLASS来生成自己的类,如果要自己写的话,即一定要在CPP中加入"STDAFX.H",而且要是第一句,这样VC才可以管理这个类。不过具体我也不大清楚,希望高手可以解释一下。
      

  8.   

    MFC又怎么样!?总有个说法,继续UP
      

  9.   

    我有两个文件:obj.h 和 obj.cppobj.h 如下:class CMyObj
    {
    private :  int MyInt ;public :  int GetMyInt( ) ;};obj.cpp 如下:#include "obj.h"int CMyObj :: GetMyInt( )
    {
        return MyInt ;
    }这个肯定没有问题,第一次写类都会犯这个错误的。我也遇到过的!哈哈!
      

  10.   

    因为VC在编译时缺省指定的pre-compile header就是stdafx.h,处理预编译头时只有碰到这个头文件,才认为pre-compiled header处理完毕——将它之前的所有头文件都做到预编译头中,供以后使用。所以如果你不包含stdafx.h,编译器将不知道何时结束处理预编译头,于是出错。
    要改变VC编译器的这种缺省行为,你可以用/Yu、/Yc(或YX)参数指定自己的预编译头(或者在源文件中用#pragma hdrstop),也可以不使用这些选项使VC不启用precompiled header。
      

  11.   

    老兄:加一个 #include "stdafx.h"!!!