Leaked source code of windows server 2003
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.

88 lines
2.0 KiB

  1. //
  2. // Debug.h
  3. //
  4. // Debug stuff for non-MFC projects.
  5. //
  6. // History:
  7. //
  8. // 3/??/96 KenSh Copied from InetSDK sample, added AfxTrace from MFC
  9. // 4/10/96 KenSh Renamed AfxTrace to MyTrace to avoid conflicts
  10. // in projects that use MFC
  11. //
  12. #ifndef __DEBUG_H__
  13. #define __DEBUG_H__
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. #ifdef _DEBUG
  18. void __cdecl MyTrace(const char* lpszFormat, ...);
  19. // void DisplayAssert(char* pszMsg, char* pszAssert, char* pszFile, unsigned line);
  20. BOOL DisplayAssert(LPCSTR pszMessage, LPCSTR pszFile, unsigned line);
  21. // #define SZTHISFILE static char _szThisFile[] = __FILE__;
  22. #define SZTHISFILE
  23. #define VERIFY(f) ASSERT(f)
  24. #define DEBUG_ONLY(f) (f)
  25. #ifndef TRACE
  26. #define TRACE ::MyTrace
  27. #endif
  28. #define THIS_FILE __FILE__
  29. #ifndef AfxDebugBreak
  30. #define AfxDebugBreak() _asm { int 3 }
  31. #endif
  32. #define ASSERTSZ(f, pszMsg) \
  33. do \
  34. { \
  35. if (!(f) && DisplayAssert(pszMsg, THIS_FILE, __LINE__)) \
  36. AfxDebugBreak(); \
  37. } while (0) \
  38. #ifndef ASSERT
  39. #define ASSERT(f) \
  40. do \
  41. { \
  42. if (!(f) && DisplayAssert(NULL, THIS_FILE, __LINE__)) \
  43. AfxDebugBreak(); \
  44. } while (0) \
  45. #endif
  46. // #define FAIL(szMsg) \
  47. // { static char szMsgCode[] = szMsg; \
  48. // DisplayAssert(szMsgCode, "FAIL", _szThisFile, __LINE__); }
  49. // // macro that checks a pointer for validity on input
  50. // //
  51. // #define CHECK_POINTER(val) if (!(val) || IsBadWritePtr((void *)(val), sizeof(void *))) return E_POINTER
  52. #else // _DEBUG
  53. #define SZTHISFILE
  54. #define VERIFY(f) ((void)(f))
  55. #define DEBUG_ONLY(f) ((void)0)
  56. inline void __cdecl MyTrace(const char* /*lpszFormat*/, ...) { }
  57. #define TRACE 1 ? (void)0 : ::MyTrace
  58. #define ASSERTSZ(fTest, err)
  59. #define ASSERT(fTest)
  60. #define FAIL(err)
  61. #define CHECK_POINTER(val)
  62. #endif // !_DEBUG
  63. #ifdef __cplusplus
  64. }
  65. #endif
  66. #endif // !__DEBUG_H__