1 /////////////////////////////////////////////////////////////////////////////
2 // Diagnostic Trace
3 //
4 #include <stdio.h>
5 #include <stdarg.h>
6 #define WIN32_LEAN_AND_MEAN
7 #include <windows.h>
8 #include <tchar.h>
9 #include "trace.h"
10 
11 
12 #ifdef _DEBUG
13 
14 #undef THIS_FILE
15 static char THIS_FILE[] = __FILE__;
16 
_DebugBreak(void)17 void _DebugBreak(void)
18 {
19     DebugBreak();
20 }
21 
Trace(TCHAR * lpszFormat,...)22 void Trace(TCHAR* lpszFormat, ...)
23 {
24     va_list args;
25     int nBuf;
26     TCHAR szBuffer[512];
27 
28     va_start(args, lpszFormat);
29     nBuf = _vsntprintf(szBuffer, sizeof(szBuffer)/sizeof(TCHAR), lpszFormat, args);
30     OutputDebugString(szBuffer);
31     // was there an error? was the expanded string too long?
32     //ASSERT(nBuf >= 0);
33     va_end(args);
34 }
35 
Assert(void * assert,TCHAR * file,int line,void * msg)36 void Assert(void* assert, TCHAR* file, int line, void* msg)
37 {
38     if (msg == NULL) {
39         printf("ASSERT -- %s occured on line %u of file %s.\n",
40                assert, line, file);
41     } else {
42         printf("ASSERT -- %s occured on line %u of file %s: Message = %s.\n",
43                assert, line, file, msg);
44     }
45 }
46 
47 #else
48 
Trace(TCHAR * lpszFormat,...)49 void Trace(TCHAR* lpszFormat, ...) { };
Assert(void * assert,TCHAR * file,int line,void * msg)50 void Assert(void* assert, TCHAR* file, int line, void* msg) { };
51 
52 #endif //_DEBUG
53 /////////////////////////////////////////////////////////////////////////////
54