【发布时间】:2012-04-13 08:32:01
【问题描述】:
我正在尝试识别我的 c++ 程序中的 memleaks。我使用 Visual Studio 2008。
我发现了一些教程,处理在使用 new 而不是 malloc 进行内存分配时识别 memleaks,这是我在 main 之上定义的:
#define __STDC_CONSTANT_MACROS
#ifdef _DEBUG
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
#define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__)
#define new DEBUG_NEW
#endif
不幸的是,我收到大量错误,您可以在此处查看:http://pastebin.com/9ax90VTg
但我想我发现了问题:定义了更近的__FILE__ 和__LINE__。当我点击__FILE__或__LINE__上的“RMB->go to definition”或“RMB->go to declaration”时,我得到:
the symbol '__FILE__' is not defined
和
the symbol '__LINE__ ' is not defined
分别。
我应该如何解决这个问题?
【问题讨论】:
标签: c++ windows visual-studio-2008 winapi