`

error C2061: syntax error : identifier 'THIS_FILE'

阅读更多
今天写个数字图像实验课的mfc代码,里面用到了stl,出现了一堆莫名其妙的错误提示。如下:
引用
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


不过还好,google一下就出来了,嗯。我们去官网看看去:
http://support.microsoft.com/default.aspx?scid=kb;en-us;143207
我的情况应该属于case2,
也就是这个:
引用

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

呵呵,然后看解决办法啊:
引用
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. Note that these definitions are no longer necessary in MFC code and can be deleted.

可以这样解决:
#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。

分享到:
评论

相关推荐

    使用VLC1.0.5进行RTSP2TS转码

    file.c:141: error: (Each undeclared identifier is reported only once file.c:141: error: for each function it appears in.) file.c:142: error: `CODA_SUPER_MAGIC' undeclared (first use in this function) ...

    Python是编译运行的验证方法

    虽然Python被说成是一种解释型语言,...1_syntax_error_identifier print “position2” 将它保存为program.py,然后在shell窗口中运行它: 复制代码 代码如下: root@dell:~$ ./program.py  File “./program.py”, l

    S7A驱动720版本

    - From the S7A power tool it wasn't possible to open the online help file. Now it can be opened and also the context-sensitive help works properly. - When the signal conditioning function "S&M" ...

    C++出错提示英汉对照表

    Argument list syntax error ----------------参数表语法错误 Array bounds missing ------------------丢失数组界限符 Array size toolarge -----------------数组尺寸太大 Bad character in paramenters ------...

    微软内部资料-SQL性能优化3

    RID A Row Identifier. Used to individually lock a single row within a table. Application A lock resource defined by an application. The lock manager knows nothing about the resource format. It simply...

    delphi编译错误.txt

    ****************************** * 编 译 错 误 信 息 * ***************************...Inline assembler syntax error 内联汇编语法错误 Instance variable ''''&lt;name&gt;'''' inaccessible here 实体变量在这里不能存取

    eac3to V3.17

    * fixed: error code not set for "source file format could not be detected" * fixed: audio resampling from/to 24.975 didn't work properly * fixed: WAV files beginning with lots of zeroes were sometimes...

    visual assist v 10.4.1632 with crack

    (case=12161) Removed C-style comment and semicolon from Encapsulate Field in Visual Basic files. (case=11160, case=4475) 7107 Object methods called on boxed string literals in C# are parsed ...

    C++ 标准 ISO 14882-2011

    1.5 Structure of this International Standard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 1.6 Syntax notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ....

    Python Power - The Comprehensive Guide (2008).pdf

    Python Syntax .................................................................................................................20 Comments ................................................................

Global site tag (gtag.js) - Google Analytics