在2005mfc的单文档框架中使用#include编译出错

ac97zy 2008-10-23 02:57:55
我新建了一个mfc的单文档框架,什么都没有改动,然后我想在view类中使用fstream,
代码如下:
#include "stdafx.h"
#include "kaofstream.h"

#include "kaofstreamDoc.h"
#include "kaofstreamView.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

#include <fstream>
using namespace std;

// CkaofstreamView

IMPLEMENT_DYNCREATE(CkaofstreamView, CView)

BEGIN_MESSAGE_MAP(CkaofstreamView, CView)
// 标准打印命令
ON_COMMAND(ID_FILE_PRINT, &CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, &CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, &CView::OnFilePrintPreview)
END_MESSAGE_MAP()

// CkaofstreamView 构造/析构

我就加了两行,然后编译出了一堆错
错误 2 error C2365: 'operator new' : redefinition; previous definition was 'function' d:\program files\microsoft visual studio 8\vc\include\xdebug 32
错误 3 error C2491: 'new' : definition of dllimport data not allowed d:\program files\microsoft visual studio 8\vc\include\xdebug 32
错误 4 error C2078: too many initializers d:\program files\microsoft visual studio 8\vc\include\xdebug 32
错误 5 error C2440: 'initializing' : cannot convert from 'int' to 'void *' d:\program files\microsoft visual studio 8\vc\include\xdebug 32
错误 6 error C2143: syntax error : missing ';' before '(' d:\program files\microsoft visual studio 8\vc\include\xdebug 32
错误 7 error C2226: syntax error : unexpected type 'size_t' d:\program files\microsoft visual studio 8\vc\include\xdebug 32
错误 8 error C2059: syntax error : ')' d:\program files\microsoft visual studio 8\vc\include\xdebug 33
警告 9 warning C4229: anachronism used : modifiers on data are ignored d:\program files\microsoft visual studio 8\vc\include\xdebug 36
错误 10 error C2365: 'operator new' : redefinition; previous definition was 'function' d:\program files\microsoft visual studio 8\vc\include\xdebug 36
错误 11 error C2491: 'new' : definition of dllimport data not allowed d:\program files\microsoft visual studio 8\vc\include\xdebug 36
错误 12 error C2078: too many initializers d:\program files\microsoft visual studio 8\vc\include\xdebug 36
错误 13 error C2440: 'initializing' : cannot convert from 'int' to 'void *' d:\program files\microsoft visual studio 8\vc\include\xdebug 36
错误 14 error C2143: syntax error : missing ';' before '[' d:\program files\microsoft visual studio 8\vc\include\xdebug 36
错误 15 error C3409: empty attribute block is not allowed d:\program files\microsoft visual studio 8\vc\include\xdebug 36
错误 16 error C2226: syntax error : unexpected type 'size_t' d:\program files\microsoft visual studio 8\vc\include\xdebug 36
错误 17 error C2059: syntax error : 'string' d:\program files\microsoft visual studio 8\vc\include\xlocale 138
错误 18 error C2091: function returns function d:\program files\microsoft visual studio 8\vc\include\xlocale 139
错误 19 error C2802: static member 'operator new' has no formal parameters d:\program files\microsoft visual studio 8\vc\include\xlocale 139
错误 20 error C2333: 'std::locale::facet::operator new' : error in function declaration; skipping function body d:\program files\microsoft visual studio 8\vc\include\xlocale 139
错误 21 error C2059: syntax error : 'string' d:\program files\microsoft visual studio 8\vc\include\xlocale 144
错误 22 error C2091: function returns function d:\program files\microsoft visual studio 8\vc\include\xlocale 146
错误 23 error C2556: 'void *(__cdecl *std::locale::facet::operator new(void))(size_t,const std::_DebugHeapTag_t &,char *,int)' : overloaded function differs only by return type from 'void *(__cdecl *std::locale::facet::operator new(void))(size_t)' d:\program files\microsoft visual studio 8\vc\include\xlocale 146
错误 24 error C2059: syntax error : 'return' d:\program files\microsoft visual studio 8\vc\include\xlocale 147
错误 25 error C2238: unexpected token(s) preceding ';' d:\program files\microsoft visual studio 8\vc\include\xlocale 147
错误 26 error C2628: 'std::locale::facet' followed by 'void' is illegal (did you forget a ';'?) d:\program files\microsoft visual studio 8\vc\include\xlocale 150
等等,
麻烦高手稍微指点一二。
...全文
746 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
ac97zy 2008-10-25
  • 打赏
  • 举报
回复
感谢4楼的答案,我今天也发现了这样
可是不知道为什么?能给个理由么?
谢谢您关注我的问题
菜牛 2008-10-23
  • 打赏
  • 举报
回复
#include <fstream> 
using namespace std;

#ifdef _DEBUG
#define new DEBUG_NEW
#endif
ac97zy 2008-10-23
  • 打赏
  • 举报
回复
再说明一下,当我把这两行放到stdafx.h中,编译就不会出错,这是为什么?
ac97zy 2008-10-23
  • 打赏
  • 举报
回复
说明一下,我的程序是自动生成的,我什么都没有改动,仅仅是加了
#include <fstream>
using namespace std;
这么两行代码呀
这么写法不是C++的标准写法么?
chenyu2202863 2008-10-23
  • 打赏
  • 举报
回复
你全局的operator new 被重定义了~

也不清楚你的环境。。。

16,471

社区成员

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

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

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