做练习时,我在visual studio.net的新建项目中选择win32项目,然后我添加了自己的两个文件:MyClass.h Myclass.cpp,然后编译就出现了...MyClass.cpp(38) fatal error C1010: 查找预编译头指令时遇到意外的文件结束我以为是我的两个文件写错了什么,所以就把文件里的所有代码全都注释,再编译,错识还是上面的,我不是很理解这个stdafx.h stdafx.cpp这两个用来邓编译的和我的MyClass.cpp有什么关系,我添加的文件怎么和预编译拉上了关系?
MyClass.cpp里// ===========================================================
// MyClass.cpp
//
#include "afxwin.h"
#include "MyClass.h"
MyClassApp theApp;
...

解决方案 »

  1.   

    这个问题在vc6中也遇到过,应该不只是vs.net里的问题。
      

  2.   

    // ===========================================================
    // MyClass.cpp
    //
    #include "stdafx.h" //try this
    #include "afxwin.h"
    #include "MyClass.h"
    MyClassApp theApp;
      

  3.   

    不行呀,这次又来新花样了:
    afxv_w32.h(18) : fatal error C1189: #error :  WINDOWS.H already included.  MFC apps must not #include <windows.h>stdafx.h里面是
    // stdafx.h : 标准系统包含文件的包含文件,
    // 或是常用但不常更改的项目特定的包含文件
    //#pragma once#define WIN32_LEAN_AND_MEAN // 从 Windows 头中排除极少使用的资料
    // Windows 头文件:
    #include <windows.h>
    // C 运行时头文件
    #include <stdlib.h>
    #include <malloc.h>
    #include <memory.h>
    #include <tchar.h>// TODO: 在此处引用程序要求的附加头
      

  4.   

    其实一切的源头是因为它使用了pch(precompiled header files)在project的setting里去了,就没一切麻烦了。大家想unix下编程可没有这些麻烦的事情啊
      

  5.   

    有没有什么办法即保留它的pch,我有能通过编译呢?
    ms搞pch不是为了做拦路虎的吧。
      

  6.   

    change your stdafx.h to comment out windows.h//  Windows  头文件:  
    //#include    <windows.h  >  
    #include    "afxwin.h "
      

  7.   

    pch可以在你不改变很大的情况下提高你的编译速度~
    否则每次都那么长时间,会疯的~在VC6.0你新建一个Win32,只要不是空白的工程就行~
    看看它的预编译文件和头文件~然后你试试7.0行不行~
    我没用过~