-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCDebug.h
More file actions
43 lines (38 loc) · 1.25 KB
/
Copy pathCDebug.h
File metadata and controls
43 lines (38 loc) · 1.25 KB
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
#pragma once
#include <shlwapi.h>
#ifdef NDEBUG
#define ASSERT(exp)
#define DPRINTF(fmt, ...)
#define OBJECTS_CHECK_POINT()
#else // ndef NDEBUG
#include <assert.h>
#define ASSERT(exp) assert(exp)
#define DPRINTF(fmt, ...) DebugPrintf(__FILE__, __LINE__, fmt, ##__VA_ARGS__)
static inline void
DebugVPrintf(const char *file, int line, const char *fmt, va_list va)
{
CHAR buf[512];
INT cch = wnsprintfA(buf, _countof(buf), "%s (%d): ", file, line);
if (_countof(buf) > cch)
wvnsprintfA(&buf[cch], _countof(buf) - cch, fmt, va);
buf[_countof(buf) - 1] = ANSI_NULL;
OutputDebugStringA(buf);
}
static inline void
DebugPrintf(const char *file, int line, const char *fmt, ...)
{
va_list va;
va_start(va, fmt);
DebugVPrintf(file, line, fmt, va);
va_end(va);
}
#if (_WIN32_WINNT >= 0x0500)
#define OBJECTS_CHECK_POINT() do { \
DPRINTF("GDI Objects: %ld, User Objects: %ld\n", \
GetGuiResources(GetCurrentProcess(), GR_GDIOBJECTS), \
GetGuiResources(GetCurrentProcess(), GR_USEROBJECTS)); \
} while (0)
#else
#define OBJECTS_CHECK_POINT()
#endif
#endif // ndef NDEBUG