the macro of watch variable value and its memory content
2015-05-05 23:07
411 查看
//replace the printf() with your log function
#include "stdafx.h"
#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;
}
#include "stdafx.h"
#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;
}
相关文章推荐
- ruby merge array of hashes based on the key and order it by number of key/value pair
- Cannot modify the return value of 'System...ClientRectangle' because it is not a variable
- the value of static variable can be changed after it's assigned
- Sometimes you will never know the true value of a moment until it becomes a memory
- all the characteristics of the Eagle Creek Centerline construct it a sensible buy and healthy value your money.
- This function has none of Deterministic,no sql,or reads sql data in its declaration and binary logging is enabled(you *might* want to use the less safe log_bin_trust_function_creators variable
- What are the different versions of JSF and when was it released?
- The content of elements must consist of well-formed character data or markup 或 The value of attribu
- It is possible that this issue is resolved by uninstalling an existing version of the apk if it is present, and then re-installing ___Error Installing APK
- A heat-filled weekend NBA Feet in the form of air jordan shoes, Foamposites, LeBron and others, so lets right it! Rajon Rondo broke necks with Foampos
- The value of CFBundleShortVersionString in your WatchKit app's Info.plist (1.0) does not match
- What is the best free memory leak detector for a C/C++ program and its plug-in DLLs
- Can't connect to X11 window server using ':1.0' as the value of the DISPLAY variable.
- Can't connect to X11 window server using ':0.0' as the value of the DISPLAY variable
- “API design is like sex: Make one mistake and support it for the rest of your life.”
- Attempting to load the view of a view controller while it is deallocating is not allowed and may res
- Can't connect to X11 window server using ':0.0' as the value of the DISPLAY variable.
- Get the content of an Iframe in Javascript – crossbrowser solution for both IE and Firefox
- What is the content of J2EE EAR, WAR and JAR files?
- Allocationand Reuse of Memory in the Shared Pool