[CPP]View PlainCopy
- Debug mode, the main output of some debugging information.
- #ifdef UNICODE
- #define _FILE_ _str2wstr (__file__)
- #define _function_ _str2wstr (__function__)
- #else
- #define _FILE_ __file__
- #define _function_ __function__
- #endif
- #define MAX_BUF_SIZE (1024)
- #define MAX_BIN_COUNT (16)
- #define MAX_BIN_SIZE (64)
- #ifdef _DEBUG
- #define NEW Debug_new
- #define DBGPRINT (lpszfmt, ...) \
- TCHAR sztext[1024] = {0}; \
- stringcchprintf (Sztext, _countof (Sztext), lpszfmt, __va_args__); \
- OutputDebugString (Sztext);
- #define DBGFAILED (dwerror) \
- LPTSTR lpszbuf = NULL; \
- TCHAR szerror[1024] = {0}; \
- FormatMessage (Format_message_allocate_buffer | Format_message_from_system, NULL, Dwerror, Lang_neutral, (LPTSTR) &lpszbuf, 0, NULL); \
- stringcchprintf (Szerror, _countof (szerror), _t ("\nerror:file:%s \n\tline:%d Function:%s () \n\treason:%s\n"), _ File_, __line__, _function_, lpszbuf); \
- OutputDebugString (szerror); \
- LocalFree (LPSZBUF);
- #define DUMPBIN (pData, dwsize) \
- TCHAR Szdata[max_bin_size] = {0}; \
- Traceloginfo (_t ("\ n-----------00-01-02-03-04-05-06-07-08-09-0a-0b-0c-0d-0e-0f"));
- For (DWORD i = 0; i < dwsize; i++) \
- { \
- if (0 = = (i% max_bin_count)) \
- { \
- Traceloginfo (Szdata); \
- stringcchprintf (Szdata, _countof_ (szdata), _t ("\n%08xh:%02x"), I, pdata[i]); \
- } \
- else \
- { \
- stringcchprintf (Szdata + _tcslen (szdata), _countof_ (szdata)-_tcslen (Szdata), _t ("%02x"), pdata[i]); \
- } \
- } \
- OutputDebugString (Szdata); \
- OutputDebugString (_t ("\ n----------------------------------------------------------\ n"));
- #else
- #define DBGPRINT (lpszfmt, ...)
- #define DBGFAILED ()
- #define DUMPBIN (PData, dwsize)
- #endif
http://blog.csdn.net/visualeleven/article/details/7211249
Debug mode application output debug debug information (ready-made macro definition for formatting printing information)