0321 error C2061 error C2091 THIS_FILE NEW
加入同事的代码,结果:
o:\微软\vs6\vc98\include\new(35) : error C2061: syntax error : identifier THIS_FILE
o:\微软\vs6\vc98\include\new(35) : error C2091: function returns function
o:\微软\vs6\vc98\include\new(35) : error C2809: operator new has no formal parameters
o:\微软\vs6\vc98\include\new(36) : error C2061: syntax error : identifier THIS_FILE
o:\微软\vs6\vc98\include\new(37) : error C2091: function returns function
o: \微软\vs6\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 operator new(void))(unsigned in
t)
o:\微软\vs6\vc98\include\new(35) : see declaration of new
o:\微软\vs6\vc98\include\new(41) : error C2061: syntax error : identifier THIS_FILE
o:\微软\vs6\vc98\include\new(42) : error C2091: function returns function
o: \微软\vs6\vc98\include\new(42) : error C2556: void *(__cdecl *__cdecl operator new(void))(unsigned int,void *) : overloaded function differs only by return type from void *(__cdecl *__cdecl operator new(void))(unsigned int)
o:\微软\vs6\vc98\include\new(35) : see declaration of new
o:\微软\vs6\vc98\include\new(42) : error C2809: operator new has no formal parameters
o:\微软\vs6\vc98\include\new(42) : error C2065: _P : undeclared identifier
o:\微软\vs6\vc98\include\memory(16) : error C2061: syntax error : identifier THIS_FILE
o:\微软\vs6\vc98\include\memory(17) : error C2091: function returns function
o: \微软\vs6\vc98\include\memory(17) : error C2784: void *(__cdecl *__cdecl operator new(void))(unsigned int,class std::allocator<`template-parameter257> &) : could not deduce template argument for void *(__cdecl *)(unsigned int,class std::alloca
tor<_Ty> &) from void *(__cdecl *)(unsigned int)
o: \微软\vs6\vc98\include\memory(17) : error C2785: void *(__cdecl *__cdecl operator new(void))(unsigned int,class std::allocator<`template-parameter257> &) and void *(__cdecl *__cdecl operator new(void))(unsigned int) have different return type
s
o:\微软\vs6\vc98\include\memory(16) : see declaration of new
o:\微软\vs6\vc98\include\memory(17) : error C2809: operator new has no formal parameters
o:\微软\vs6\vc98\include\memory(20) : error C2954: template definitions cannot nest
Generating Code...
Error executing cl.exe.
Creating browse info file...
宏与头文件错误的冲突问题
程序如下:
// SisSocket.cpp : implementation file
//
#include "stdafx.h"
#include "DataServer.h"
#include "SisSocket.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#include "DataServerDlg.h"
经指点,将
// SisSocket.cpp : implementation file
//
#include "stdafx.h"
#include "DataServer.h"
#include "SisSocket.h"
#include "DataServerDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
//...其他代码
问题解决,出在new重定义上
注:THIS_FILE为static char[],在debug时内容为本文件路径,供输出错误信息使用。
就是把
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
放到所有 INCLUDE 的后面