Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

113 lines
2.5 KiB

  1. #ifndef DEBUG_H
  2. #define DEBUG_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #include <windows.h>
  7. //
  8. // Macros for debugging support.
  9. //
  10. // ASSERT(exp) Popup a dialogbox, if exp is FALSE
  11. // ASSERTMSG(exp, msg) Similar to ASSERT. Except the msg is displayed instead of the expression
  12. //
  13. // Use TRACE(x) for output, where x is a list of printf()-style parameters.
  14. // TRACEn() is TRACE with n printf arguments
  15. // For example, TRACE2("This shows how to print stuff, like a string %s, and a number %u.","string",5);
  16. //
  17. // USE VERIFY for expressions executed for both debug and release version
  18. //
  19. #undef ASSERT
  20. #undef ASSERTMSG
  21. /*
  22. //
  23. // Used by atl
  24. //
  25. #ifdef _ATL_NO_DEBUG_CRT
  26. #define _ASSERTE ASSERT
  27. #define _ASSERT ASSERT
  28. #endif
  29. */
  30. //
  31. // Trace out the function name
  32. //
  33. #ifdef ENABLE_PROFILE
  34. #define PROFILE(pszFunctionName) TRACE(pszFunctionName)
  35. #else
  36. #define PROFILE(pszFunctionName) ((void)0)
  37. #endif
  38. //
  39. // Define TRACE here.
  40. //
  41. #define TRACE_INFO TRACE
  42. #define TRACE_INFO1 TRACE1
  43. #define TRACE_INFO2 TRACE2
  44. #define TRACE_INFO3 TRACE3
  45. #define TRACE_ERROR TRACE
  46. #define TRACE_ERROR1 TRACE1
  47. #define TRACE_ERROR2 TRACE2
  48. #define TRACE_ERROR3 TRACE3
  49. #ifdef DBG
  50. #define DEBUG
  51. #endif
  52. #if ( defined(DEBUG) || defined(_DEBUG) )
  53. extern "C" void TraceMessageA(const CHAR *pszFmt, ...) ;
  54. #define TRACE(pszFmt) TraceMessageA(pszFmt)
  55. #define TRACE1(pszFmt, arg1) TraceMessageA(pszFmt, arg1)
  56. #define TRACE2(pszFmt, arg1, arg2) TraceMessageA(pszFmt, arg1, arg2)
  57. #define TRACE3(pszFmt, arg1, arg2, arg3) TraceMessageA(pszFmt, arg1, arg2, arg3)
  58. #else
  59. #define TRACE(pszFmt) ((void)0)
  60. #define TRACE1(pszFmt, arg1) ((void)0)
  61. #define TRACE2(pszFmt, arg1, arg2) ((void)0)
  62. #define TRACE3(pszFmt, arg1, arg2, arg3) ((void)0)
  63. #endif
  64. #if ( defined(DEBUG) || defined(_DEBUG))
  65. #ifdef UNICODE
  66. #define AssertMessage AssertMessageW
  67. #else
  68. #define AssertMessage AssertMessageA
  69. #endif
  70. void AssertMessage(const TCHAR *pszFile, unsigned nLine, const TCHAR *pszMsg);
  71. #define ASSERT(x) (void)((x) || (AssertMessage(TEXT(__FILE__),__LINE__,TEXT(#x)),0))
  72. #define ASSERTMSG(exp, msg) (void)((exp) || (AssertMessage(TEXT(__FILE__),__LINE__,msg),0))
  73. #define VERIFY(x) ASSERT(x)
  74. // {ASSERT(pObj);pObj->AssertValid();}
  75. #define ASSERT_VALID(pObj) ((ASSERT(pObj),1) && ((pObj)->AssertValid(),1))
  76. #else // DEBUG
  77. #define ASSERT_VALID(pObj)
  78. #define ASSERT(x) ((void)0)
  79. #define ASSERTMSG(exp, msg) ((void)0)
  80. #define VERIFY(x) (x)
  81. #endif
  82. #ifdef __cplusplus
  83. }
  84. #endif
  85. #endif