编译错误如下
Myapp.cpp
d:\vcpro\新建文件夹 (2)\my001\myapp.cpp(31) : fatal error C1010: unexpected end of file while looking for precompiled header directive
Error executing cl.exe.Myapp.obj - 1 error(s), 0 warning(s)
头文件如下:
//***********************************************
//  MyApp.h 
//class CMyApp:public CWinApp  //见下②
{
public:
virtual BOOL InitInstance();
};class CMyFrame:public CFrameWnd
{
public:
CMyFrame();
protected:
afx_msg void OnLButtonDown(UINT nFlags,CPoint point);
afx_msg void OnPaint();
DECLARE_MESSAGE_MAP()
};
CPP文件如下
#include "afxwin.h"
#include "myapp.h"
CMyApp theApp;BOOL CMyApp::InitInstance ()
{
m_pMainWnd=new CMyFrame();
m_pMainWnd->ShowWindow (m_nCmdShow);
m_pMainWnd->UpdateWindow ();
return TRUE;
}BEGIN_MESSAGE_MAP(CMyFrame,CFrameWnd)
ON_WM_LBUTTONDOWN()
ON_WM_PAINT()
END_MESSAGE_MAP()CMyFrame::CMyFrame(){
Create(NULL,"MYAPP Application");
}
void CMyFrame::OnLButtonDown (UINT nFlags,CPoint point)
{
TRACE("Entering CMyFrame::OnLButtonDown - %lx,%d,%d\n",
(long)nFlags,point.x ,point.y);
}
void CMyFrame::OnPaint ()
{
CPaintDC dc(this);
dc.TextOut(0,0,"Hello World!");
}

解决方案 »

  1.   

    预编译头文件找不到吧, 在工程里看看include路径,有没有问题
      

  2.   

    只在.cpp文件中加#include "stdafx.h"
    并且要放在最上面,
    要么你少了一个  }
      

  3.   

    1。预编译头文件找不到。
    2。你可能在if else中丢失{ }匹配符或if _debug endif之类的匹配丢失
      

  4.   

    我在CPP文件最前加了#include "stdafx.h"
    编译过去了,可运行出现了以下错误:
    debug Assertion failed!
    program:d:\vcpro\my001\debug\my001.exe
    file:appcore.cpp
    line:85
    for information on how your program can cause
    an assertion failure,see the Visual C++ documentaion on asserts.
    (press retry to debug the application)
      

  5.   

    把debug目录删除,重新执行一下
      

  6.   

    你不如New不要把太多时间放在这种问题上
      

  7.   

    把DEGUG的目录删了也不行!
      

  8.   

    这里有问题
    BOOL CMyApp::InitInstance ()
    {
    m_pMainWnd=new CMyFrame();
    m_pMainWnd->ShowWindow (m_nCmdShow);
    m_pMainWnd->UpdateWindow ();
    return TRUE;
    }
    至少应该LoadFrame吧