1*c2c66affSColin Finck /////////////////////////////////////////////////////////////////////////////
2*c2c66affSColin Finck // Diagnostic Trace
3*c2c66affSColin Finck //
4*c2c66affSColin Finck #ifndef __TRACE_H__
5*c2c66affSColin Finck #define __TRACE_H__
6*c2c66affSColin Finck 
7*c2c66affSColin Finck #ifdef _DEBUG
8*c2c66affSColin Finck 
9*c2c66affSColin Finck #ifdef _X86_
10*c2c66affSColin Finck #define BreakPoint()        _asm { int 3h }
11*c2c66affSColin Finck #else
12*c2c66affSColin Finck #define BreakPoint()        _DebugBreak()
13*c2c66affSColin Finck #endif
14*c2c66affSColin Finck 
15*c2c66affSColin Finck #ifndef ASSERT
16*c2c66affSColin Finck #define ASSERT(exp)                                 \
17*c2c66affSColin Finck {                                                   \
18*c2c66affSColin Finck     if (!(exp)) {                                   \
19*c2c66affSColin Finck         Assert(#exp, __FILE__, __LINE__, NULL);     \
20*c2c66affSColin Finck         BreakPoint();                               \
21*c2c66affSColin Finck     }                                               \
22*c2c66affSColin Finck }                                                   \
23*c2c66affSColin Finck 
24*c2c66affSColin Finck #define ASSERTMSG(msg, exp)                         \
25*c2c66affSColin Finck {                                                   \
26*c2c66affSColin Finck     if (!(exp)) {                                   \
27*c2c66affSColin Finck         Assert(#exp, __FILE__, __LINE__, msg);      \
28*c2c66affSColin Finck         BreakPoint();                               \
29*c2c66affSColin Finck     }                                               \
30*c2c66affSColin Finck }
31*c2c66affSColin Finck #endif
32*c2c66affSColin Finck 
33*c2c66affSColin Finck //=============================================================================
34*c2c66affSColin Finck //  MACRO: TRACE()
35*c2c66affSColin Finck //=============================================================================
36*c2c66affSColin Finck 
37*c2c66affSColin Finck #define TRACE  Trace
38*c2c66affSColin Finck 
39*c2c66affSColin Finck 
40*c2c66affSColin Finck #else   // _DEBUG
41*c2c66affSColin Finck 
42*c2c66affSColin Finck //=============================================================================
43*c2c66affSColin Finck //  Define away MACRO's ASSERT() and TRACE() in non debug builds
44*c2c66affSColin Finck //=============================================================================
45*c2c66affSColin Finck 
46*c2c66affSColin Finck #ifndef ASSERT
47*c2c66affSColin Finck #define ASSERT(exp)
48*c2c66affSColin Finck #define ASSERTMSG(msg, exp)
49*c2c66affSColin Finck #endif
50*c2c66affSColin Finck 
51*c2c66affSColin Finck #define TRACE 0 ? (void)0 : Trace
52*c2c66affSColin Finck 
53*c2c66affSColin Finck #endif // !_DEBUG
54*c2c66affSColin Finck 
55*c2c66affSColin Finck 
56*c2c66affSColin Finck void Assert(void* assert, TCHAR* file, int line, void* msg);
57*c2c66affSColin Finck void Trace(TCHAR* lpszFormat, ...);
58*c2c66affSColin Finck 
59*c2c66affSColin Finck 
60*c2c66affSColin Finck #endif // __TRACE_H__
61*c2c66affSColin Finck /////////////////////////////////////////////////////////////////////////////
62