#ifdef _DEBUG #undef THIS_FILE static char THIS_FILE[]=__FILE__; #define new DEBUG_NEW...
来源:互联网 发布:淘宝代购申诉凭证 编辑:程序博客网 时间:2024/05/22 11:33
原文:http://blog.csdn.net/Beyond_cn/archive/2009/09/02/4509797.aspx
转帖保存:
收藏
情况1:
#ifdef _DEBUG
virtual void AssertValid() const; //assert(断言)valid(有效的,正确的)
virtual void Dump(CDumpContext& dc) const; //存储上下文
#endif
这两个函数是调试用的,第一个函数检查可用性,即是否有效
第二个函数如果未更改的话,最终调用的是Cwnd::Dump();
输出窗口类名,标题名等一系列信息(在输出窗口中)
#ifdef _DEBUG
#endif
这是条件编译,即如果有#define _DEBUG这两个函数会编译,否则忽略,
当你用debug生成时(相对于release)开发环境则自动的加上这个宏定义,这两个函数有效。
情况2:
#ifdef _DEBUG // 判断是否定义_DEBUG
#undef THIS_FILE // 取消THIS_FILE的定义
static char THIS_FILE[]=__FILE__; // 定义THIS_FILE指向文件名
#define new DEBUG_NEW // 定义调试new宏,取代new关键字
#endif // 结束
如果定义了_DEBUG,表示在调试状态下编译,因此相应修改了两个符号的定义
THIS_FILE是一个char数组全局变量,字符串值为当前文件的全路径,这样在Debug版本中当程序出错时出错处理代码可用这个变量告诉你是哪个文件中的代码有问题。
定义 _DEBUG后,由于定义了_DEBUG,编译器确定这是一个调试,编译#ifdef _DEBUG和#endif之间的代码。#undef 表示清除当前定义的宏,使得THIS_FILE无定义。
__FILE__ 是编译器能识别的事先定义的ANSI C 的6个宏之一。
DEBUG_NEW定位内存泄露并且跟踪文件名.
////////////////////////////////////////////////////////////////////////
情况3:
#ifdef _DEBUG //如果是debug状态
#undef THIS_FILE //清除THIS_FILE
static char THIS_FILE[]=__FILE__; //定义THIS_FILE为__FILE__(这是当前文件全路径名字)
#define new DEBUG_NEW //定义new为DEBUG_NEW(这个可以检测到内 //存泄露之类的问题,其实就是可以使用crt开头的那几个调试函数)
#endif
ANSI C 的6个宏:
6个分别是
__DATE__
__FILE__
__LINE__
__STDC__
__TIME__
__TIMESTAMP__
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/Beyond_cn/archive/2009/09/02/4509797.aspx
- #ifdef _DEBUG #undef THIS_FILE static char THIS_FILE[]=__FILE__; #define new DEBUG_NEW...
- #ifdef _DEBUG #undef THIS_FILE static char THIS_FILE[]=__FILE__; #define new DEBUG_NEW...
- #ifdef _DEBUG #undef THIS_FILE static char THIS_FILE[]=__FILE__; #define new DEBUG_NEW...
- #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif 语句解释
- #ifdef _DEBUG #undef THIS_FILE static char THIS_FILE[]=__FILE__; #define new DEBUG_NEW #endif
- #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif
- #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif 语句解释
- #ifdef _DEBUG #undef THIS_FILE static char THIS_FILE[]=__FILE__; #endif
- #ifdef _DEBUG #undef THIS_FILE static char THIS_FILE[]=__FILE__; #endif
- #ifdef _DEBUG #undef THIS_FILE static char THIS_FILE[]=__FILE__; #endif
- #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE
- 关于MFC中的#ifdef _DEBUG #undef THIS_FILE static char THIS_FILE[]=__FILE__; #endif
- 关于MFC中的#ifdef _DEBUG #undef THIS_FILE static char THIS_FILE[]=__FILE__; #endif
- #undef THIS_FILE static char THIS_FILE[] = __FILE__;
- C++ static char THIS_FILE[] = __FILE__;
- C++ static char THIS_FILE[] = __FILE__;
- C++ static char THIS_FILE[] = __FILE__
- #ifdef _DEBUG #define new DEBUG_NEW #endif
- PIO Cache Coherency Issue on Cortex A9
- linux磁盘管理命令
- 外键约束
- linux命令之 crontab 的使用
- AutoMySQLBackup简单的MySQL备份方法
- #ifdef _DEBUG #undef THIS_FILE static char THIS_FILE[]=__FILE__; #define new DEBUG_NEW...
- XCode: ld waning boost consthas different visibility (default)
- 对FrameBuffer的一夜hack
- 我的创业 ——从一万六到几百万,从个人拼搏到团队作战
- tomcat 中文URL路径无法访问解决方案
- configure svn server on win
- 串口ic读卡器c#代码
- webmin 安装及使用问题
- Linux logo和屏幕光标