-
Notifications
You must be signed in to change notification settings - Fork 85
/
Debug.h
57 lines (36 loc) · 2.56 KB
/
Debug.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 DEBUG_H
#define DEBUG_H
// uncomment the following to enable debug mode
//\
#define DEBUG
#ifdef DEBUG
#include <Windows.h>
HANDLE GetConsoleHandle();
#define PRINTW( STR, ... ) \
if (1) { \
HANDLE hConsole = NULL; \
if ((hConsole = GetConsoleHandle()) == NULL){} \
else{ \
LPWSTR buf = (LPWSTR)HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, 1024 ); \
if ( buf != NULL ) { \
int len = wsprintfW( buf, STR, __VA_ARGS__ ); \
WriteConsoleW( hConsole, buf, len, NULL, NULL ); \
HeapFree( GetProcessHeap(), 0, buf ); \
} \
} \
}
#define PRINTA( STR, ... ) \
if (1) { \
HANDLE hConsole = NULL; \
if ((hConsole = GetConsoleHandle()) == NULL){} \
else{ \
LPWSTR buf = (LPWSTR)HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, 1024 ); \
if ( buf != NULL ) { \
int len = wsprintfA( buf, STR, __VA_ARGS__ ); \
WriteConsoleA( hConsole, buf, len, NULL, NULL ); \
HeapFree( GetProcessHeap(), 0, buf ); \
} \
} \
}
#endif // DEBUG
#endif // !DEBUG_H