vc6.0转换Vs2008 错误error C2365: 'operator new'

jcdd188 2011-04-28 05:53:27
网上说是new operator重载问题
代码里只有一处有
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
我把他注释掉了 一样有这个错误

1>d:\program files\microsoft visual studio 9.0\vc\include\xdebug(32) : warning C4229: anachronism used : modifiers on data are ignored
1>d:\program files\microsoft visual studio 9.0\vc\include\xdebug(32) : error C2365: 'operator new' : redefinition; previous definition was 'function'
1>d:\program files\microsoft visual studio 9.0\vc\include\xdebug(32) : error C2078: too many initializers
1>d:\program files\microsoft visual studio 9.0\vc\include\xdebug(32) : error C2440: 'initializing' : cannot convert from 'int' to 'void *'
1> Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
1>d:\program files\microsoft visual studio 9.0\vc\include\xdebug(32) : error C2143: syntax error : missing ';' before '('
1>d:\program files\microsoft visual studio 9.0\vc\include\xdebug(32) : error C2226: syntax error : unexpected type 'size_t'
1>d:\program files\microsoft visual studio 9.0\vc\include\xdebug(33) : error C2059: syntax error : ')'
1>d:\program files\microsoft visual studio 9.0\vc\include\xdebug(36) : warning C4229: anachronism used : modifiers on data are ignored
1>d:\program files\microsoft visual studio 9.0\vc\include\xdebug(36) : error C2365: 'operator new' : redefinition; previous definition was 'function'
1>d:\program files\microsoft visual studio 9.0\vc\include\xdebug(36) : error C2078: too many initializers
1>d:\program files\microsoft visual studio 9.0\vc\include\xdebug(36) : error C2440: 'initializing' : cannot convert from 'int' to 'void *'
1> Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
1>d:\program files\microsoft visual studio 9.0\vc\include\xdebug(36) : error C2143: syntax error : missing ';' before '['
1>d:\program files\microsoft visual studio 9.0\vc\include\xdebug(36) : error C3409: empty attribute block is not allowed
1>d:\program files\microsoft visual studio 9.0\vc\include\xdebug(36) : error C2226: syntax error : unexpected type 'size_t'
1>d:\program files\microsoft visual studio 9.0\vc\include\xlocale(143) : error C2059: syntax error : 'string'
1>d:\program files\microsoft visual studio 9.0\vc\include\xlocale(144) : error C2091: function returns function
1>d:\program files\microsoft visual studio 9.0\vc\include\xlocale(144) : error C2802: static member 'operator new' has no formal parameters
1>d:\program files\microsoft visual studio 9.0\vc\include\xlocale(144) : error C2333: 'std::locale::facet::operator new' : error in function declaration; skipping function body
1>d:\program files\microsoft visual studio 9.0\vc\include\xlocale(149) : error C2059: syntax error : 'string'
1>d:\program files\microsoft visual studio 9.0\vc\include\xlocale(151) : error C2091: function returns function
1>d:\program files\microsoft visual studio 9.0\vc\include\xlocale(151) : 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)'
...全文
757 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
godion 2012-04-05
  • 打赏
  • 举报
回复
I found the cause of the problem, I added the header file after the
following declarations

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

The header file must be added before those.

Ref: http://marc.info/?l=log4cxx-user&m=108972054520600
昵称测试 2011-08-06
  • 打赏
  • 举报
回复
我也遇到同样的 问题 已然存在
jcdd188 2011-04-29
  • 打赏
  • 举报
回复
问题解决了 是其他地方重载了operator new 与xdebug里的发生了冲突 我直接删掉就好了 谢谢楼上两位
xiaopoy 2011-04-28
  • 打赏
  • 举报
回复
这个肯定是因为你include头文件的顺序有问题。不妨检查下出错的源代码里,头文件里分析include了哪些,头文件里include的也统计出来。这样一个个去除include的目标来排查重复include的问题。
hhh_hao 2011-04-28
  • 打赏
  • 举报
回复
#define new DEBUG_NEW, //不要干这种事情....

3,882

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 其它技术问题
社区管理员
  • 其它技术问题社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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