error C2061: syntax error : identifier 'THIS_FILE'

今天写个数字图像实验课的mfc代码,里面用到了stl,出现了一堆莫名其妙的错误提示。如下:
[quote] error C2091: function returns function
d:\program files\microsoft visual studio\vc98\include\new(35) : error C2809: 'operator new' has no formal parameters
d:\program files\microsoft visual studio\vc98\include\new(36) : error C2061: syntax error : identifier 'THIS_FILE'
d:\program files\microsoft visual studio\vc98\include\new(37) : error C2091: function returns function

d:\program files\microsoft visual studio\vc98\include\new(35) : see declaration of 'new'
d:\program files\microsoft visual studio\vc98\include\new(41) : error C2061: syntax error : identifier 'THIS_FILE'
d:\program files\microsoft visual studio\vc98\include\new(42) : error C2091: function returns function

d:\program files\microsoft visual studio\vc98\include\new(35) : see declaration of 'new'
d:\program files\microsoft visual studio\vc98\include\new(42) : error C2809: 'operator new' has no formal parameters
d:\program files\microsoft visual studio\vc98\include\new(42) : error C2065: '_P' : undeclared identifier
d:\program files\microsoft visual studio\vc98\include\memory(16) : error C2061: syntax error : identifier 'THIS_FILE'
d:\program files\microsoft visual studio\vc98\include\memory(17) : error C2091: function returns function

d:\program files\microsoft visual studio\vc98\include\memory(16) : see declaration of 'new'
d:\program files\microsoft visual studio\vc98\include\memory(17) : error C2809: 'operator new' has no formal parameters
d:\program files\microsoft visual studio\vc98\include\memory(20) : error C2954: template definitions cannot nest[/quote]

不过还好,google一下就出来了,嗯。我们去官网看看去:
[url]http://support.microsoft.com/default.aspx?scid=kb;en-us;143207[/url]
我的情况应该属于case2,
也就是这个:
[quote]
Case Two
In addition, you may get this different set of errors:
{include directory}\new.h(80) : error C2061: syntax error : identifier 'THIS_FILE'
{include directory}\new.h(80) : error C2091: function returns function
{include directory}\new.h(80) : error C2809: 'operator new' has no formal parameters#endif
{include directory}\new.h(80) : error C2065: 'ptr' : undeclared identifier
[/quote]
呵呵,然后看解决办法啊:
[quote]The second set of errors occurs if you add the STL include directive after the following definitions and do not include New.h among your include directives:
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

Including New.h will work around this problem as well.[b] [color=red]Note that these definitions are no longer necessary in MFC code and can be deleted.[/color][/b] [/quote]
可以这样解决:

#include <vector>
#include <algorithm>
using namespace std;
/*
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
*/

把std的那些东西放到mFC声明的代码的前面,或者直接注释掉MFC代码。rebulid all。pass。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值