__dbg.h
#ifndef __HSS_DBG_HSS__
#define __HSS_DBG_HSS__ /**************************************************************************************************\
* 2009-06-28 调试信息输出的宏版
(1) 一定起作用的宏
__trace, __trace_file, __trace_fmt, __trace_end
(2) 需要定义 __dbg__才有作用的宏
__if, _if, __trace_dbg, __trace_file_dbg, __trace_fmt_dbg, __trace_end_dbg
(宏名dbg在后面,是为了在搜索__trace的时候可以找到所有的宏)
(3) 用法示例:
__trace "a=%d b=%d\r\n", a, b); __trace_end
__trace_file "a=%d b=%d\r\n", a, b); __trace_end
//注意:这个宏有参数 ,并且在宏的参数括号的后面,不能有逗号
__trace_fmt(__FILE__, __LINE__, TRUE) "a=%d b=%d", a, b); __trace_end
其中__FILE__可以替换为其他文件名,若是全路径会只显示文件名
(4) __if 是长格式版,显示条件的内容
(5) _if 是短格式版,不显示条件的内容,仅显示条件的值
\**************************************************************************************************/
#include <shlwapi.h>
#pragma comment(lib, "shlwapi.lib")
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define __trace_end if (__sztrace && __sztrace[0]) \
OutputDebugStringA(__sztrace); \
}
#define __trace \
{ \
char __sztrace[260] = {0}; \
_snprintf(__sztrace, sizeof(__sztrace),
#define __trace_file \
{ \
char __sztrace[260] = {0}; \
int _n = _snprintf(__sztrace, sizeof(__sztrace)-1, "%08X %s/%d ", GetCurrentThreadId(), strrchr(__FILE__, '\\') + 1, __LINE__); \
_snprintf(__sztrace+_n, sizeof(__sztrace)-_n-1,
#define __trace_fmt(file, line, error) \
{ \
char __sztrace[260] = {0}; \
int __n = 0; \
if (file && ((char*)file)[0]) \
{ \
LPCTSTR __p = strrchr(file, '\\'); \
if (__p == 0) \
__p = file; \
__n += _snprintf(__sztrace+__n, sizeof(__sztrace)-1-__n, "%s ", __p); \
} \
if (line) \
{ \
__n += _snprintf(__sztrace+__n, sizeof(__sztrace)-1-__n, "/%d ", line); \
} \
if (error) \
{ \
int se = GetLastError(); \
LPSTR __lpMsgbuf = 0; \
if (FormatMessage( \
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, \
NULL, \
se, \
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), \
(LPSTR) & __lpMsgbuf, \
0, \
NULL) \
) \
{ \
if (__lpMsgbuf && __lpMsgbuf[0]) \
{ \
__n += _snprintf(__sztrace+__n, sizeof(__sztrace)-1-__n, "%s (%d) ", __lpMsgbuf, se); \
} \
if (__lpMsgbuf) \
{ \
LocalFree( __lpMsgbuf ); \
} \
} \
} \
__n += _snprintf(__sztrace+__n, sizeof(__sztrace)-1-__n,
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//sample : __trace_bytes("profix", pData, cbData) __trace_end;
#define __trace_bytes(Profix, pData, cbData) \
{ \
int __size = cbData * 3 + (Profix == 0 ? 0 : strlen(Profix)) + 32; \
char* __sztrace = (char*)alloca(__size); \
LPBYTE __p = (LPBYTE)pData; \
if (__sztrace) \
{ \
int __n = _snprintf(__sztrace, __size-1, "%s", Profix); \
for (int __l = 0 ; __l < cbData ; __l ++) \
{ \
DWORD __d = (DWORD)__p[__l]; \
__n += _snprintf(__sztrace + __n, __size-1-__n, "%02X ", __d); \
} \
__n += _snprintf(__sztrace + __n, __size-1-__n, "(%d)", cbData); \
__sztrace[__n] = 0; \
__sztrace[__size-1] = 0; \
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define __FL__ __trace_file "\r\n");__trace_end;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#ifdef __dbg__
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define __trace_end_dbg __trace_end
#define __trace_dbg __trace
#define __trace_file_dbg __trace_file
#define __trace_fmt_dbg __trace_fmt
/**************************************************************************************************\
* 2009-06-28
显示程序的分支和判断的值
长格式:__if 显示判断的条件的文本
短格式:_if 不显示判断的条件的文本
\**************************************************************************************************/
#define __if_false(x) \
{ \
char __szif[256] = {0}; \
if (!(x)) \
{ \
_snprintf(__szif, sizeof(__szif)-1, "%s/%d %d == ("#x")\r\n", strrchr(__FILE__, '\\') + 1, __LINE__, (x)); \
OutputDebugStringA(__szif); \
} \
} \
if (x)
///////////////////////////////////////////////////////////////////////////////////////////////////
#define __if_true(x) \
{ \
char __szif[256] = {0}; \
if (x) \
{ \
_snprintf(__szif, sizeof(__szif)-1, "%s/%d %d == ("#x")\r\n", strrchr(__FILE__, '\\') + 1, __LINE__, (x)); \
OutputDebugStringA(__szif); \
} \
} \
if (x)
///////////////////////////////////////////////////////////////////////////////////////////////////
#define __if(x) \
{ \
char __szif[256] = {0}; \
if (x) \
{ \
_snprintf(__szif, sizeof(__szif)-1, "%s/%d %d == ("#x")\r\n", strrchr(__FILE__, '\\') + 1, __LINE__, (x)); \
} \
else \
{ \
_snprintf(__szif, sizeof(__szif)-1, "%s/%d %d == ("#x")\r\n", strrchr(__FILE__, '\\') + 1, __LINE__, (x)); \
} \
OutputDebugStringA(__szif); \
} \
if (x)
///////////////////////////////////////////////////////////////////////////////////////////////////
#define _if(x) \
{ \
char __szif[256] = {0}; \
if (x) \
{ \
_snprintf(__szif, sizeof(__szif)-1, "%s/%d %d \r\n", strrchr(__FILE__, '\\') + 1, __LINE__, (x)); \
} \
else \
{ \
_snprintf(__szif, sizeof(__szif)-1, "%s/%d %d \r\n", strrchr(__FILE__, '\\') + 1, __LINE__, (x)); \
} \
OutputDebugStringA(__szif); \
} \
if (x)
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#else
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define _if(x) if(x)
#define __if(x) if(x)
#define __if_true(x) if(x)
#define __if_false(x) if(x)
#define __trace_end_dbg }
#define __trace_dbg if (0) { (
#define __trace_file_dbg if (0) { (
#define __trace_fmt_dbg if (0) { (
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#endif
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#endif
__dbg.h的更多相关文章
- 关于 AVI 的一些代码
#ifndef __HSS_AUTO_REVISE_AVI_FRAMERATE_HSS__ #define __HSS_AUTO_REVISE_AVI_FRAMERATE_HSS__ /******* ...
- APUE中fcntl.h的使用及O_SYNC在Mac与Ubuntu下的测试
此部分测试涉及到APUE V3中,第三章的图3-12到图3-14. 通过fcntl.h提供的功能,修改fd的文件属性,本处增加O_SYNC功能,并测试其效果. 本文涉及代码: tree ch3 ch3 ...
- 关于apue.3e中apue.h的使用
关于apue.3e中apue.h的使用 近来要学一遍APUE第三版,并于此开博做为记录. 先下载源文件: # url: http://http//www.apuebook.com/code3e.htm ...
- YYModel 源码解读(二)之NSObject+YYModel.h (1)
本篇文章主要介绍 _YYModelPropertyMeta 前边的内容 首先先解释一下前边的辅助函数和枚举变量,在写一个功能的时候,这些辅助的东西可能不是一开始就能想出来的,应该是在后续的编码过程中 ...
- YYModel 源码解读(一)之YYModel.h
#if __has_include(<YYModel/YYModel.h>) FOUNDATION_EXPORT double YYModelVersionNumber; FOUNDATI ...
- error RC1015: cannot open include file 'afxres.h' 解决办法
在为WindowsPhone8程序添加本地化的过程中遇到这个问题: 问题原因就是afxres.h文件缺失,下载它,放到VS安装目录下的VS\include目录下就可以了(选择目录的时候注意对应对版本) ...
- afxcomctl32.h与afxcomctl32.inl报错
afxcomctl32.h与afxcomctl32.inl报错 编译公司一个几年前的老项目,是从VC6.0升级到VS2005的. 1.编译时报缺少头文件,于是附件包含目录,于是出现了以下报错: 1&g ...
- C标准头文件<math.h>
定义域错误可以理解为超出了函数的适用范围,如果发生了定义域错误,设errno为EDOM 如果结果不能表示为double值,则发生值域错误,如果结果上溢,则函数返回HUGE_VAL的值,设errno为E ...
- C标准头文件<ctype.h>
主要包括了一些字符识别和转换函数 字符判断 isalnum() //函数原型 #include<ctype.h> int isalum(int c); 功能:如果输入的字符是字母(alph ...
随机推荐
- SQLite的基本使用
SQLite 创建表 SQLite 的 CREATE TABLE 语句用于在任何给定的数据库创建一个新表.创建基本表,涉及到命名表.定义列及每一列的数据类型. 语法 CREATE TABLE 语句的基 ...
- 【.NET深呼吸】Zip文件操作(1):创建和读取zip文档
.net的IO操作支持对zip文件的创建.读写和更新.使用起来也比较简单,.net的一向作风,东西都准备好了,至于如何使用,请看着办. 要对zip文件进行操作,主要用到以下三个类: 1.ZipFile ...
- 软件工程的引入:Scrum开发框架总结
俗话说,自己写的代码,6个月后也是别人的代码……复习!复习!复习!涉及的知识点如下: 软件工程概念 敏捷开发过程scrum 一.什么是软件工程?请用一句话描述. 软件工程是一门研究性的学科:它用工程化 ...
- HTML5 学习总结(二)——HTML5新增属性与表单元素
一.HTML5新增属性 1.1.contextmenu contextmenu的作用是指定右键菜单. <!DOCTYPE html> <html> <head> & ...
- web前端性能调优
最近2个月一直在做手机端和电视端开发,开发的过程遇到过各种坑.弄到快元旦了,终于把上线了.2个月干下来满满的的辛苦,没有那么忙了自己准备把前端的性能调优总结以下,以方便以后自己再次使用到的时候得于得心 ...
- Android动画:模拟开关按钮点击打开动画(属性动画之平移动画)
在Android里面,一些炫酷的动画确实是很吸引人的地方,让然看了就赏心悦目,一个好看的动画可能会提高用户对软件的使用率.另外说到动画,在Android里面支持3种动画: 逐帧动画(Frame Ani ...
- Basic Tutorials of Redis(3) -Hash
When you first saw the name of Hash,what do you think?HashSet,HashTable or other data structs of C#? ...
- Entity Framework实现多列排序
aList.OrderBy(a => a.WIndex).ThenBy(a=>a.KIndex) 类似sql:order by WIndex,KIndex
- 设计模式(七)适配器模式(Adapter Pattern)
一.引言 在实际的开发过程中,由于应用环境的变化(例如使用语言的变化),我们需要的实现在新的环境中没有现存对象可以满足,但是其他环境却存在这样现存的对象.那么如果将“将现存的对象”在新的环境中进行调用 ...
- Yii 2.x RESTful 应用 - 类图
配置url管理器配置请求数据解析器配置用户控制器 ['GET', 'PUT', 'PATCH', 'DELETE', 'HEAD', 'OPTIONS']