小段代码,提示fatal error C1010: unexpected end of file while looking for precompiled header directive不知道怎么解决?谢谢

hd506lg 2003-04-12 11:04:27
// vc4_singleSample.cpp : Defines the entry point for the application.
//
#include <afxwin.h>
#include "vc4_singleSample.h"

CMyApp theapp;

bool CMyApp::InitInstance()
{
m_pMainWnd = new CMyFrame;
m_pMainWnd->ShowWindow(m_nCmdShow);
m_pMainWnd->UpdateWindow();
return true;
}

DECLARE_MESSAGE_MAP(CMyFrame,CFrameWnd)
ON_WM_PAINT()
END_MESSAGE_MAP()

CMyFrame::CMyFrame()
{
Create(NULL,"SFDFD FDS");
}

void CMyFrame::OnPaint()
{
CPaint dc(this);
dc.TextOut(0,0,"afefefefefefefefef");
}


///////////////vc4_singleSample.h/////////////
#include <afxwin.h>

class CMyApp : public CWinApp
{
public :
virtual bool InitInstance();

};

class CMyFrame : public CFrameWnd
{
public:
CMyFrame();

protected:
afx_msg void OnPaint();
DECLARE_MESSAGE_MAP()
};


...全文
61 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
wangxxx 2003-04-14
  • 打赏
  • 举报
回复
你的内部代码很多都错了,旁边没MSDN没法帮你改,至于你说的那个错误,正如上面人说的,只要把vc4_singleSample.cpp中的#include <afxwin.h>删掉,在vc4_singleSample.h中加入
stdafx.h中的头文件#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#include <afxdisp.h> // MFC Automation classes
#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls就够了,其他错误:
1。DECLARE_MESSAGE_MAP(CMyFrame,CFrameWnd) ——BEGIN_MESSAGE_MAP
ON_WM_PAINT()
END_MESSAGE_MAP()
2。Create(NULL,"SFDFD FDS");缺少必要参数,详情见MSDN,我就发现这么多,hehe
用户 昵称 2003-04-14
  • 打赏
  • 举报
回复
#include <stdafx.h>
hd506lg 2003-04-13
  • 打赏
  • 举报
回复
// vc4_singleSample.cpp : Defines the entry point for the application.
#include "stdafx.h"
#include "vc4_singleSample.h"

CMyApp theapp;

bool CMyApp::InitInstance()
{
m_pMainWnd = new CMyFrame;
m_pMainWnd->ShowWindow(m_nCmdShow);
m_pMainWnd->UpdateWindow();
return true;
}

DECLARE_MESSAGE_MAP(CMyFrame,CFrameWnd)
ON_WM_PAINT()
END_MESSAGE_MAP()

CMyFrame::CMyFrame()
{
Create(NULL,"SFDFD FDS");
}

void CMyFrame::OnPaint()
{
CPaint dc(this);
dc.TextOut(0,0,"afefefefefefefefef");
}


class CMyApp : public CWinApp
{
public :
virtual bool InitInstance();

};

class CMyFrame : public CFrameWnd
{
public:
CMyFrame();

protected:
afx_msg void OnPaint();
DECLARE_MESSAGE_MAP()
};

并设置project->setting->c/c++->选precompiled headers选not using precompiled headers



这就是包含的全部源代码
项目种还包含stdafx.h stdafx.cpp二文件,再没其他什么东西了
pcman1990 2003-04-13
  • 打赏
  • 举报
回复
(1) foxmail(萧遥)说得对,这是由VC的预编译机制所要求而引起的。解决方法,要么关掉预编译开关,要么指定预编译使用的头文件,也就是foxmail(萧遥)一开始所说的方法一和方法二;
(2) 用方法一,应该不会出现你后来所说的问题;
(3) 用方法二,出现你的问题是可能的,因为#include "stdafx.h"后,afxwin.h会被include,这和你程序中用其他方式添加的#include <windows.h>会有冲突。解决办法是把#include <windows.h>的地方全部用#include "stdafx.h"来代替
hd506lg 2003-04-13
  • 打赏
  • 举报
回复
去掉全部的 afxwin.h
并设置project->setting->c/c++->选precompiled headers选not using precompiled headers
后,
报错:'CWinApp' : base class undefined
'CFrameWnd' : base class undefined
error C2144: syntax error : missing ';' before type 'void'
。。。。。
等等很多
foxmail 2003-04-12
  • 打赏
  • 举报
回复
stdafx.h中已经有#include <afxwin.h> 了
每个cpp文件什么加上#include "stdafx.h"


我觉得
1 project->setting->c/c++->选precompiled headers选not using precompiled headers
应该不会报错了阿
foxmail 2003-04-12
  • 打赏
  • 举报
回复
去掉#include <afxwin.h>
只加#include "stdafx.h"
不过你的有stdafx.h这个文件(可以新建一个MFC工程,再复制过来)
fatal error C1010: unexpected end of file while looking for precompiled header directive
这个错误是标准的工程配置错误,因为编译的时候需要预编译头文件,而工程里面没有
hd506lg 2003-04-12
  • 打赏
  • 举报
回复
代码全在上面了,请问有什么地方不对呢?
E17 2003-04-12
  • 打赏
  • 举报
回复
不是什么大问题。。
我决的是 #include 的不对
hd506lg 2003-04-12
  • 打赏
  • 举报
回复
上述的二种方法都试了,还报错:
fatal error C1189: #error : WINDOWS.H already included. MFC apps must not #include <windows.h>

不知怎么解决,谢谢
cxjlw 2003-04-12
  • 打赏
  • 举报
回复
只有一个空框架,没有创建视图,就没有客户区,也就没有客户区设备上下文,所以就不能调用dc->TextOut(..);
foxmail 2003-04-12
  • 打赏
  • 举报
回复
1 project->setting->c/c++->选precompiled headers选not using precompiled headers
或者
2 在最前面加上#include "stdafx.h"

16,472

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧