the macro of watch variable value and its memory content
来源:互联网 发布:手机淘宝取消合并付款 编辑:程序博客网 时间:2024/05/22 11:36
//replace the printf() with your log function
#include <stddef.h>
typedef int INT;
typedef unsigned char BYTE;
typedef short SHORT;
#define WatchVarVal(fmt, Var){\
printf(#Var##" value: "##fmt##"\n", Var);\
}
// the local variable _i must be different from the input argument Var in this macro,otherwise error will occur.
#define WatchVarMem(Var){ \int _i; \
printf(#Var##" addr: 0x%x"##", size: %d bytes\n", &Var, sizeof(Var));\
for(_i = 0; _i < sizeof(Var); _i++)\
printf("Byte[%d]:0x%x\n", _i, *((unsigned char *)&Var + _i));\
}
int _tmain(int argc, _TCHAR* argv[])
{
INT iVar = 1023;
double dblVar = 2.34567;
WatchVarVal("%d", iVar);
WatchVarMem(iVar);
WatchVarVal("%f", dblVar);
WatchVarMem(dblVar);
getchar();
return 0;
}
0 0
- the macro of watch variable value and its memory content
- VS2010 can not watch the value of local variables
- the macro # and ## (typing...)
- The implementation of anonymous methods in C# and its consequences
- The story of getting Twitter data and its “missing middle”
- The Definition of Key Value Coding and Key Value Observing
- On the Way to the Web: The Secret History of the Internet and Its Founders
- The Search : How Google and Its Rivals Rewrote the Rules of Business and Transformed Our Culture
- The probability of variable
- Can't connect to X11 window server using ':0.0' as the value of the DISPLAY variable.
- set command will return the value of the argument( variable, actually )
- 运行Liferay报错:Please set the environment variable ANT_OPTS to the recommended value of
- the environment variable java_home (with the value of ) does not point to a valid jvm installation
- Can't connect to X11 window server using ':0.0' as the value of the DISPLAY variable.
- 运行Liferay报错:Please set the environment variable ANT_OPTS to the recommended value of
- Liferay:Please set the environment variable ANT_OPTS to the recommended value of
- Postscript III:The Operand Stack of PostScript: Arrays, Variables, Loops and Macro Definitions
- SWFLoader: the size of SWF document and content
- 前端web
- 使iframe高度和宽度适应浏览器可视区域大小
- 程序员如何让自己更值钱?
- CreateProcess
- session缓存及extjs的ajax的async的问题
- the macro of watch variable value and its memory content
- SpringMVC 使用JSR-303进行校验 @Valid
- poj 2195 Going Home(最小费用最大流)
- PHP数组的遍历
- 第三章第十六题
- 什么是优雅的代码
- 动态规划求解矩阵链乘法
- AngularJS笔记
- 挑选空调注意事项