【转】编译时遇到如下错误error C2061: syntax error : identifier 'THIS_FILE'
2009-05-19 16:17
696 查看
原文:
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 function
.../new(35) : error C2809: 'operator new' has no formal parameters
.../new(36) : error C2061: syntax error : identifier 'THIS_FILE'
.../new(37) : error C2091: function returns function
很奇怪,昨天这个类测试过的,没问题呀,上网查了一下,终于发现问题之所在。
解决方法:
新加入的类是CSelectServer,该类里用到了STL,该类在HouServer.cpp里调用,在HouServer.cpp包含CSelectServer.h文件时写成了如下这样:
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#include "SelectServer.h"
上网搜索一遍,发现出现这些错误与STL头文件和VC6在CPP文件里生成的几行代码有关,STL头文件是指以下几行:
#pragma warning (disable:4786)
#include <list>
using namespace std;
VC6在CPP文件里生成的几行代码指以下几行:
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
STL头文件要写在VC6在CPP文件里生成的几行代码之前,谨记!我的 "SelectServer.h"文件里包含了STL头文件,当在其它cpp文件里包含"SelectServer.h"文件时一定要将#include"SelectServer.h"放在VC6生成的那几行代码之前!所以改成下面这样就编译通过。
#include "SelectServer.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
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 function
.../new(35) : error C2809: 'operator new' has no formal parameters
.../new(36) : error C2061: syntax error : identifier 'THIS_FILE'
.../new(37) : error C2091: function returns function
很奇怪,昨天这个类测试过的,没问题呀,上网查了一下,终于发现问题之所在。
解决方法:
新加入的类是CSelectServer,该类里用到了STL,该类在HouServer.cpp里调用,在HouServer.cpp包含CSelectServer.h文件时写成了如下这样:
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#include "SelectServer.h"
上网搜索一遍,发现出现这些错误与STL头文件和VC6在CPP文件里生成的几行代码有关,STL头文件是指以下几行:
#pragma warning (disable:4786)
#include <list>
using namespace std;
VC6在CPP文件里生成的几行代码指以下几行:
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
STL头文件要写在VC6在CPP文件里生成的几行代码之前,谨记!我的 "SelectServer.h"文件里包含了STL头文件,当在其它cpp文件里包含"SelectServer.h"文件时一定要将#include"SelectServer.h"放在VC6生成的那几行代码之前!所以改成下面这样就编译通过。
#include "SelectServer.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
相关文章推荐
- 编译时遇到如下错误error C2061: syntax error : identifier 'THIS_FILE'
- 编译时遇到如下错误error C2061: syntax error : identifier 'THIS_FILE'
- 编译时遇到如下错误error C2061: syntax error : identifier 'THIS_FILE'
- 编译时遇到如下错误error C2061: syntax error : identifier 'THIS_FILE'
- 编译过程中弹出new(35) : error C2061: syntax error : identifier 'THIS_FILE'问题的原因及解决方法
- 编译时遇到如下错误error C2061: syntax error : identifier 'THIS_FILE'
- VC6提示 error C2061: syntax error : identifier 'THIS_FILE' 错误的解决办法
- 'FILE' : illegal use of this type as an expression编译错误的解决
- error:VC编译错误:error C2065: '_beginthreadex' : undeclared identifier
- 编译错误:microsoft visual studio 9.0\vc\include\cstdio(42) : error C2059: syntax error : ':'
- 编译boost程序出现如下错误fatal error LNK1104: cannot open file 'libboost_system-vc100-mt-gd-1_54.lib'的解决方法
- error C2061: syntax error : identifier 'THIS_FILE'
- ndk编译错误:error: 'nullptr' was not declared in this scope
- 编译错误error C2370: 'THIS_FILE' : redefinition的解决方法
- vs2010 库函数问题:objidl.h(11266) : error C2061: syntax error : identifier '__RPC__out_xcount_part'
- vc6.0 转 vs2008 时 遇到这样的错误时“BSCMAKE: error BK1506 : cannot open file './Debug/ex73View.sbr': No such file or directory”
- syntax error : missing ';' before identifier 'PVOID64' (DSHOW开发编译错误 winnt.h)
- 2014-04-08工作日志:error C2061: syntax error : identifier 'LPPROFILEINFO'
- error C2061: syntax error : identifier 'THIS_FILE'
- 编译错误:syntax error : identifier '__RPC__in'