【发布时间】:2013-12-30 12:52:10
【问题描述】:
我正在尝试使用VS2008内存泄漏工具,但我完全没有构建它。
最简单的场景效果很好,但是当我尝试使用 CObject 时 - 它无法编译
这是代码(它是一个新创建的控制台应用程序)
#include "stdafx.h"
#ifdef _DEBUG
#ifndef DBG_NEW
#define DBG_NEW new ( _NORMAL_BLOCK , __FILE__ , __LINE__ )
#define new DBG_NEW
#endif
#endif // _DEBUG
#define _AFXDLL
#include "afx.h"
class DRV : public CObject {};
int _tmain(int argc, _TCHAR* argv[])
{
DRV *d = new DRV;
}
这会导致:错误 C2059:语法错误:afx.h 中的“常量”:
void* PASCAL operator new(size_t nSize);
如果我尝试将 #ifdef _DEBUG 移动到 #include "afx.h" 下方,我会得到:
error C2661: 'CObject::operator new' : no overloaded function takes 4 arguments
上线:
DRV *d = new DRV;
那么 - 我做错了什么? 我可以使用内置的 VS2008 内存泄漏检测器吗? 请帮忙
【问题讨论】:
标签: memory-leaks memory-leak-detector