源码中有如下一段代码
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
编译时出现如下的一堆错误:
d:\program files\microsoft visual studio\vc98\include\new(35) : error C2061: syntax error : identifier 'THIS_FILE'
d:\program files\microsoft visual studio\vc98\include\new(35) : 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(37) : error C2556: 'void *(__cdecl *__cdecl operator new(void))(unsigned int,const struct std::nothrow_t &)' : overloaded function differs only by return type from 'void *(__cdecl *__cdecl op
erator new(void))(unsigned int)'
....
请教怎样解决这样的问题,还有就是前面的那段源代码是什么意思?源码是别人写的.
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
编译时出现如下的一堆错误:
d:\program files\microsoft visual studio\vc98\include\new(35) : error C2061: syntax error : identifier 'THIS_FILE'
d:\program files\microsoft visual studio\vc98\include\new(35) : 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(37) : error C2556: 'void *(__cdecl *__cdecl operator new(void))(unsigned int,const struct std::nothrow_t &)' : overloaded function differs only by return type from 'void *(__cdecl *__cdecl op
erator new(void))(unsigned int)'
....
请教怎样解决这样的问题,还有就是前面的那段源代码是什么意思?源码是别人写的.
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
好像.cpp文件中最开头都是这样的嘛,自动定义的啊。
你试试把define new那条放到第二行?我看好像都是那样的。
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/* Compile options needed: /c /D_DEBUG /DNOMINMAX
*/ #include <afxwin.h> // or stdafx.h in a default AppWizard project.
//#include <new.h> // Required to avoid this problem. #ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif namespace std {
#include <vector.h>
}
但是还会存在如下的错误
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(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
是不是还是缺少什么头文件呀??急
我想缺少THIS_FILE的声明定义吧。