编译过程中弹出new(35) : error C2061: syntax error : identifier 'THIS_FILE'问题的原因及解决方法

AI权益加码!Claude Code、Cursor等20+工具免费用! 购周边限时加赠Coding Plan Lite,畅享主流AI工具!学习进阶更高效! 阅读详情

http://www.99inf.net/SoftwareDev/VC/27092.htm

 

原本一直正常的程序,今天编译时突然弹出以下内容

c:/program files/microsoft visual studio/vc98/include/new(35) : error C2061: syntax error : identifier 'THIS_FILE'
c:/program files/microsoft visual studio/vc98/include/new(35) : error C2091: function returns function
c:/program files/microsoft visual studio/vc98/include/new(35) : error C2809: 'operator new' has no formal parameters
c:/program files/microsoft visual studio/vc98/include/new(36) : error C2061: syntax error : identifier 'THIS_FILE'
c:/program files/microsoft visual studio/vc98/include/new(37) : error C2091: function returns function

等等

 

最后在网上查明后才知道原因,在往mfc类添加头文件时,需注意

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

这一段内容,添加的头文件必须在该段程序之前,否则编译不通过。

 

例如:

 

#include "Config.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

 

正确

 


以下的错误,将头文件放在该段程序之后将编译不通过
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

 

#include "Config.h"

编译时遇到如下错误error C2061: syntax error : identifier 'THIS_FILE' 阅读详情

相关推荐

C++编译错误syntax error : identifier 'THIS_FILE' 解决方法

你到代码里搜索 THIS_FILE看是不是它定义在别的头文件前面了,如果是,把它们的头文件紧跟到Stdafx.h后面 我遇到过这问题,这样搞定的 今天遇到个编译错误:..\vc98\include\new(35) : error C2061: syntax error : identifier 'THIS_FILE',我的某个.cpp中是这样写的: #include "stda...

weixin_30721077的博客 523

【转】编译时遇到如下错误error C2061: syntax error : identifier 'THIS_FILE'

原文:http://blog.csdn.net/hzyong_c/archive/2009/02/20/3913692.aspx 上午写程序时,加入了前些写的一个类,编译时遇到如下错误:...error C2061: syntax error : identifier THIS_FILE.../new(35) : error C2091: function returns func

code09的专栏 1720

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...

tiger-hu 416

VC6提示 error C2061: syntax error : identifier 'THIS_FILE' 错误的解决办法

http://www.cnblogs.com/silentmj/archive/2010/05/06/1728787.html 今天在编译一段以前写的代码时候,遇到了这样的错误 --------------------Configuration: AppSharePlugin - Win32 Debug-------------------- Compiling... AppSharePlug

2274

C2061: syntax error : identifier 'THIS_FILE'

       关于宏与头文件错误的冲突问题解决            宏与头文件错误的冲突问题 程序如下: // SisSocket.cpp : implementation file // #include "stdafx.h" #include "DataServer.h" #include "SisSocket.h" #ifdef _DEBUG #define new...

weixin_33774308的博客 206

error C2061: syntax error : identifier 'string'

编译时候报错:error C2061: syntax error : identifier ‘string’分析原因:没有加入 #include<string> using namespace std;通常是由于std命名空间引起的

Nabryant的博客 6465

error C2061: syntax error : identifier 'CAMSchedule'

DirectShow中的例子,在编译过程中经常会出现这样的错误:Error 1 error C2061: syntax error : identifier CAMSchedule c:/programfiles/microsoftsdks/windows/v6.0/samples/multimedia/directshow/baseclasses/refclock.h80 这主

jtujtujtu的专栏 6967

c语言程序c2061,C++错误C2061:语法错误:标识符

Error 1 error C2061: syntax error : identifier 'stammdaten'Error 2 error C2660: 'Test_Lohnab::Gehaltsrechner' : function does not take 1 argumentsError 3 error C2511: 'int Test_Lohnab::Gehaltsrechner(...

weixin_33800724的博客 3544

error C2061语法错误:标识符

学习C++的过程中,使用vs2019写代码,代码没有变红,但是编译不通过,原因是在其中一个类A中定义了枚举值,在类B中需要使用这个枚举值,所以类B的头文件包含了A.h,而A.h中又包含了B.h,所以重复包含,解决方法是在去掉其中一个头文件中的包含,例如:去掉A.h中的#include"B.h",改用class B;代替,然后在A.cpp中包含#includeB.h。

weixin_45961921的博客 2322

error C2061: syntax error : identifier 'SHFILEINFOW' // 无法解析的外部符号 wWinMain,该符号在函数 WinMainCRTStartup

1>StdAfx.cpp 1>E:\Program Files\Windows CE Tools\wce600\DbAu13xx\include\MIPSII\shellapi.h(321) : error C2061: syntax error : identifier 'SHFILEINFOW' 1>C:\Program Files\Microsoft Visual Studio 8\VC

chenyujing1234的专栏 3884
上一篇: c语言中浮点数的表示形式
下一篇: 别人写的通信录,以后可以参考一下
james_hw
博客等级 码龄18年 66粉丝 30原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值