forked from yuqilin/CodesAndNotes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ShowDebug.h
57 lines (40 loc) · 1.32 KB
/
ShowDebug.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#ifndef _SHOW_DEBUG_H_
#define _SHOW_DEBUG_H_
#ifdef ENABLE_SHOW_DEBUG
#define PREFIX_A(text) text
#define PREFIX_W(text) L##text
#define PREFIX "PlayerCore"
#define __STRINGA(text) text
#define __STRINGW(text) L##text
#define STRINGA(text) __STRINGA(text)
#define STRINGW(text) __STRINGW(text)
#define DEBUG_PREFIX_A STRINGA(PREFIX)
#define DEBUG_PREFIX_W STRINGW(PREFIX)
#include <windows.h>
#include <stdio.h>
#ifdef _UNICODE
#define ShowDebug ShowDebugW
#else
#define ShowDebug ShowDebugA
#endif
inline void ShowDebugA(const char* pcszFormat, ... )
{
char szBuffer[1024] = DEBUG_PREFIX_A;
va_list vl;
va_start(vl, pcszFormat);
_vsnprintf_s(szBuffer+strlen(szBuffer), _countof(szBuffer)-strlen(szBuffer), _TRUNCATE, pcszFormat, vl);
va_end(vl);
::OutputDebugStringA(szBuffer);
}
inline void ShowDebugW(const wchar_t* pcszFormat, ... )
{
wchar_t szBuffer[1024] = DEBUG_PREFIX_W;
va_list vl;
va_start(vl, pcszFormat);
_vsnwprintf_s(szBuffer+wcslen(szBuffer), _countof(szBuffer)-wcslen(szBuffer), _TRUNCATE, pcszFormat, vl);
va_end(vl);
::OutputDebugStringW(szBuffer);
}
#else // ENABLE_SHOW_DEBUG
#define ShowDebug(...)
#endif // ENABLE_SHOW_DEBUG