我写了 一个c的test.h 和test.c文件,把它们加到console application中没问题,但是把他们加到带界面的mfc application中就就会报错;
:\documents and settings\administrator\桌面\test.p(7) : fatal error C1010: unexpected end of file while looking for precompiled header directive
你不信可以试验一下
那位知道这是为什么

解决方案 »

  1.   

    代码如下:
    test.h:
       #ifndef _TEST_
      #define _TEST_
      extern int sum(int a ,int b);
      #endiftest.c:
       #include "test.h"
       int sum(int a ,int b)
        {
    return a + b;
         }
      

  2.   

    加下面这行到你的.c文件中
    #include "stdafx.h"
      

  3.   

    加上
    #include "stdafx.h"
      

  4.   

    1、project->Settings->Setting for选择现在编译的版本
    2、从工程中的Source Files中选择test.c
    3、从C/C++栏的Category选择Precompiled Headers,然后从下面选择Not using Precompiled Headers即可
      

  5.   

    在c文件中加入
    #include "stdafx.h"
    把test.c改为test.cpp(如果纯c语言可以不用改)
      

  6.   

    加上#include "stdafx.h"
    应该可以的
      

  7.   

    我把#inlcude "stdafx.h"加到. c中了,可是有出现了下面的问题:
    c:\documents and settings\administrator\桌面\testvxmap high quality\rotate.c(2) : fatal error C1853: 'Debug/TestVxMap.pch' is not a precompiled header file created with this compiler