我自己建的类,然后都分成H和CPP文件了
然后就建了一个空的Win32工程,把自己的CPP和H加进去,一编译就出错,
错误如下
d:\testp\expreesion.cpp(270) : fatal error C1010: unexpected end of file while looking for precompiled header directive
Max.cpp
d:\testp\max.cpp(107) : fatal error C1010: unexpected end of file while looking for precompiled header directive
Generating Code...
Error executing cl.exe.
这是MSDN对错误的解释
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.
这是我加头文件的方式
#include <string.h>
#include <iostream.h>class expreesion  
{
public:
.................#include "expreesion.h"void expreesion::Seta0(int a_0)
{
a0 = a_0;
}void expreesion::Seta1(int a_1)
{
......................#include <stdlib.h>
#include <malloc.h>
#include "expreesion.h"#define MAX 3
class Max
{
public:
Max(int r1 , int c1);
.................
#include "Max.h"Max::Max(int r1 , int c1)
{
int i , j;    row = r1; col = c1;
........................但是这几个文件在Win32 Console Application下组建成工程后时一点问题都没有,我的目的是编一个运算方面的类,单个单个CPP编的,所有算法实现以后,我要给它做个用户界面,所以建一个Win32 Application,然后把它们加进来,响应消息时执行相关对象的函数。以上就是错误的内容了,先谢谢各位大哥了,帮小弟解答一下吧

解决方案 »

  1.   

    没有预编译头
    如果使用Win32 Application的话建议使用第二个模板创建工程,即:a simple win32 application
    如果要做界面的话,不要用Win32 application了,比较烦,还是用MFC吧
      

  2.   

    #include "stdafx.h"  ??????
    晕。
      

  3.   

    如果发生错误的文件是由其他的C代码文件添加进入当前工程而引起的,则Alt+F7进入当前工程的Settings,选择C/C++选项卡,从Category组合框中选中Precompiled  Headers,选择Not  Using  Precompiled  headers。确定  
    如果发生错误的文件原本是该工程中的,则检查该文件头部有没有#include  "stdafx.h"语句,没有的话添加。  
    如果还不行,也有可能是定义的类或结构体等最后忘了加分号,注意一下。
      

  4.   

    你自己写了stdafx.h吗
    在你的每个实现文件里都包含它
      

  5.   

    你只要在你自己建的类的.cpp文件里加上:
    #include "stdafx.h"
    如果还不行就再加上
    #include "ProjectName.h"  //ProjectName.h是指你的工程App的头文件
      

  6.   

    要么加上#include "stdafx.h"
    要么在编译选项里去掉预编译头