我自己编了个编函数,想把它放在一个cpp中,我通过“工程——添加工程——新建...”方法加入了一个.h和.cpp文件。但编绎的时候,出现以下错误:
d:\sh\rdsk\my.cpp(6) : fatal error C1010: unexpected end of file while looking for precompiled header directive谁能帮我解决一下,100分想送!!!

解决方案 »

  1.   

    该问题我也碰过,也是提示unexpected end of file...,开始以为是文件尾出错,查了半天也没找到;后来,怀疑是文件隐含着奇怪的字符(不知道是哪些),采用注释法逐步注释掉代码,再编译,如果通过,则是该代码引起的,重新照着写,然后删除该段代码。
      

  2.   

    在头文件中加入
    #ifndefine _my_h
    #define _my_h....
    //your file#endif
    这就可以了
      

  3.   

    Fatal Error C1010
    unexpected end of file while looking for precompiled header directiveA precompiled header was specified, but it did not contain a precompiled header directive.This error can be caused by specifying an incorrect file as a header file, or by specifying an include file with the /Yu (Use Precompiled Header) command line option that is not listed in the source file as an include file.
    如果代码是从网页上copy后在*.cpp, *.h文件中粘贴的话,很可能会出现VC不能识别的字符,如|、:、;等,这符号的不同很难看得出,最好是自己重新再敲一次键盘,注意不要打开输入法
      

  4.   

    wwwllg(wwwllg)所说的,还是不行的。
      

  5.   

    在.cpp中
    加入 #include "stdafx.h"
      

  6.   

    在VC++中,单击菜单栏上的Insert - new class, 弹出一对话框,在class type 中选择Generic Class,输入所要加的文件名,就可以生成相应的.h 和.cpp 文件。把原来.h 和.cpp文件中的内容复制到其中即可。利用VC++自己生成的文件,不必自己填写内容。
      

  7.   

    之所以要加入#include "stdafx.h"
    是因为你在编译的时候选择了预编译头文件.
    可以在project->setting->c++ : category中选择Precomplid headers
      然后选择是否设置预编译头文件.
      

  8.   

    用向导一般不会出错的,#include "stdafx.h"要加上