home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / appwiz / customwz / template / debug.h < prev    next >
C/C++ Source or Header  |  1998-03-05  |  2KB  |  57 lines

  1. #if !defined($$FILE_NAME_SYMBOL$$_INCLUDED_)
  2. #define $$FILE_NAME_SYMBOL$$_INCLUDED_
  3.  
  4. /////////////////////////////////////////////////////////////////////////////
  5. // Diagnostic support
  6.  
  7. #ifdef _PSEUDO_DEBUG
  8.  
  9. #undef TRACE
  10. #undef VERIFY
  11. #undef ASSERT
  12. #undef THIS_FILE
  13. #undef TRACE0
  14. #undef TRACE1
  15. #undef TRACE2
  16. #undef TRACE3
  17.  
  18.  
  19. // Note: file names are still ANSI strings (filenames rarely need UNICODE)
  20. BOOL AssertFailedLine(LPCSTR lpszFileName, int nLine);
  21.  
  22. void Trace(LPCTSTR lpszFormat, ...);
  23.  
  24. // by default, debug break is asm int 3, or a call to DebugBreak, or nothing
  25. #if defined(_M_IX86)
  26. #define CustomDebugBreak() _asm { int 3 }
  27. #else
  28. #define CustomDebugBreak() DebugBreak()
  29. #endif
  30.  
  31. #define TRACE              ::Trace
  32. #define THIS_FILE          __FILE__
  33. #define ASSERT(f) \
  34.     do \
  35.     { \
  36.     if (!(f) && AssertFailedLine(THIS_FILE, __LINE__)) \
  37.         CustomDebugBreak(); \
  38.     } while (0) \
  39.  
  40. #define VERIFY(f)          ASSERT(f)
  41.  
  42. // The following trace macros are provided for backward compatiblity
  43. //  (they also take a fixed number of parameters which provides
  44. //   some amount of extra error checking)
  45. #define TRACE0(sz)              ::Trace(_T(sz))
  46. #define TRACE1(sz, p1)          ::Trace(_T(sz), p1)
  47. #define TRACE2(sz, p1, p2)      ::Trace(_T(sz), p1, p2)
  48. #define TRACE3(sz, p1, p2, p3)  ::Trace(_T(sz), p1, p2, p3)
  49.  
  50. #endif // !_PSEUDO_DEBUG
  51.  
  52.  
  53. //{{AFX_INSERT_LOCATION}}
  54. // $$INSERT_LOCATION_COMMENT$$
  55.  
  56. #endif // !defined($$FILE_NAME_SYMBOL$$_INCLUDED_)
  57.