home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / com / inole2 / inc / dbgout.h < prev    next >
C/C++ Source or Header  |  1995-05-03  |  3KB  |  111 lines

  1. /*
  2.  * DBGOUT.H
  3.  *
  4.  * Useful debugging output macros that compile to nothing and
  5.  * eliminate ugly #ifdef DEBUGs from source code.  Note that
  6.  * string literals do not need TEXT() around them as this file
  7.  * includes them.
  8.  *
  9.  * Copyright (c)1993-1995 Microsoft Corporation, All Rights Reserved
  10.  *
  11.  * Kraig Brockschmidt, Microsoft
  12.  * Internet  :  kraigb@microsoft.com
  13.  * Compuserve:  INTERNET>kraigb@microsoft.com
  14.  */
  15.  
  16. #ifndef _DBGOUT_H
  17. #define _DBGOUT_H
  18.  
  19. #ifdef DEBUG
  20.  
  21. //Basic debug macros
  22. #define D(x)        {x;}
  23.  
  24. #define ODS(x)  \
  25.     {\
  26.     TCHAR        szDebug[128];\
  27.     OutputDebugString(TEXT(x));\
  28.     wsprintf(szDebug, TEXT(" [%s, %u]\r\n"), (LPTSTR)__FILE__, __LINE__);\
  29.     OutputDebugString(szDebug);\
  30.     }
  31.  
  32. #define ODSsz(f, s) \
  33.     {\
  34.     TCHAR       szDebug[128];\
  35.     wsprintf(szDebug, TEXT(f), (LPTSTR)s);\
  36.     OutputDebugString(szDebug);\
  37.     wsprintf(szDebug, TEXT(" [%s, %u]\r\n"), (LPTSTR)__FILE__, __LINE__);\
  38.     OutputDebugString(szDebug);\
  39.     }
  40.  
  41.  
  42. #define ODSu(f, u)  \
  43.     {\
  44.     TCHAR       szDebug[128];\
  45.     wsprintf(szDebug, TEXT(f), (UINT)u);\
  46.     OutputDebugString(szDebug);\
  47.     wsprintf(szDebug, TEXT(" [%s, %u]\r\n"), (LPTSTR)__FILE__, __LINE__);\
  48.     OutputDebugString(szDebug);\
  49.     }
  50.  
  51.  
  52. #define ODSlu(f, lu) \
  53.     {\
  54.     TCHAR       szDebug[128];\
  55.     wsprintf(szDebug, TEXT(f), (DWORD)lu);\
  56.     OutputDebugString(szDebug);\
  57.     wsprintf(szDebug, TEXT(" [%s, %u]\r\n"), (LPTSTR)__FILE__, __LINE__);\
  58.     OutputDebugString(szDebug);\
  59.     }
  60.  
  61. #define ODSlulu(f, lu1, lu2) \
  62.     {\
  63.     TCHAR       szDebug[128];\
  64.     wsprintf(szDebug, TEXT(f), (DWORD)lu1, (DWORD)lu1);\
  65.     OutputDebugString(szDebug);\
  66.     wsprintf(szDebug, TEXT(" [%s, %u]\r\n"), (LPTSTR)__FILE__, __LINE__);\
  67.     OutputDebugString(szDebug);\
  68.     }
  69.  
  70. #define ODSszu(f, s, u)     \
  71.     {\
  72.     TCHAR       szDebug[128];\
  73.     wsprintf(szDebug, TEXT(f), (LPTSTR)s, (UINT)u);\
  74.     OutputDebugString(szDebug);\
  75.     wsprintf(szDebug, TEXT(" [%s, %u]\r\n"), (LPTSTR)__FILE__, __LINE__);\
  76.     OutputDebugString(szDebug);\
  77.     }
  78.  
  79.  
  80. #define ODSszlu(f, s, lu)   \
  81.     {\
  82.     TCHAR       szDebug[128];\
  83.     wsprintf(szDebug, TEXT(f), (LPTSTR)s, (DWORD)lu);\
  84.     OutputDebugString(szDebug);\
  85.     wsprintf(szDebug, TEXT(" [%s, %u]\r\n"), (LPTSTR)__FILE__, __LINE__);\
  86.     OutputDebugString(szDebug);\
  87.     }
  88.  
  89.  
  90. #define ASSERT(condition) \
  91.     {\
  92.     if (!(condition))\
  93.         ODS("Assertion Failure");\
  94.     }
  95.  
  96. #else   //NO DEBUG
  97.  
  98. #define D(x)
  99. #define ODS(x)
  100.  
  101. #define ODSsz(f, s)
  102. #define ODSu(f, u)
  103. #define ODSlu(f, lu)
  104. #define ODSszu(f, s, u)
  105. #define ODSszlu(f, s, lu)
  106. #define ASSERT(c)
  107.  
  108. #endif //DEBUG
  109.  
  110. #endif //_DBGOUT_H
  111.