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.

88 lines
2.1 KiB

  1. // Copyright (C) 1997 Microsoft Corporation. All rights reserved.
  2. // *********************** Assertion Definitions ************************** //
  3. // Get rid of any previously defined versions
  4. #undef ASSERT
  5. #undef VERIFY
  6. #ifndef THIS_FILE
  7. #define THIS_FILE __FILE__
  8. #endif
  9. // *********************** Function Prototypes **************************** //
  10. PCSTR GetStringResource(int idString);
  11. // *********************** Debug/Internal Functions ********************** //
  12. #ifdef INTERNAL
  13. void AssertErrorReport(PCSTR pszExpression, UINT line, LPCSTR pszFile);
  14. // IASSERT is available in INTERNAL retail builds
  15. #define IASSERT(exp) \
  16. { \
  17. ((exp) ? (void) 0 : \
  18. AssertErrorReport(#exp, __LINE__, THIS_FILE)); \
  19. }
  20. #define IASSERT_COMMENT(exp, pszComment) \
  21. { \
  22. ((exp) ? (void) 0 : \
  23. AssertErrorReport(pszComment, __LINE__, THIS_FILE)); \
  24. }
  25. #else
  26. #define IASSERT(exp)
  27. #define IASSERT_COMMENT(exp, pszComment)
  28. #endif
  29. #ifdef _DEBUG
  30. #define ASSERT(exp) \
  31. { \
  32. ((exp) ? (void) 0 : \
  33. AssertErrorReport(#exp, __LINE__, THIS_FILE)); \
  34. }
  35. #define ASSERT_COMMENT(exp, pszComment) \
  36. { \
  37. ((exp) ? (void) 0 : \
  38. AssertErrorReport(pszComment, __LINE__, THIS_FILE)); \
  39. }
  40. #define FAIL(pszComment) AssertErrorReport(pszComment, __LINE__, THIS_FILE);
  41. #define VERIFY(exp) ASSERT(exp)
  42. #define VERIFY_RESULT(exp1, exp2) ASSERT((exp1) == (exp2))
  43. #define DEBUG_ReportOleError doReportOleError
  44. void doReportOleError(HRESULT hres);
  45. #define DBWIN(psz) { OutputDebugString(psz); OutputDebugString("\n"); }
  46. #define CHECK_POINTER(val) if (!(val) || IsBadWritePtr((void *)(val), sizeof(void *))) return E_POINTER
  47. int MsgBox(int idString, UINT nType = MB_OK);
  48. int MsgBox(PCSTR pszMsg, UINT nType = MB_OK);
  49. #else // non-debugging version
  50. #define ASSERT(exp)
  51. #define ASSERT_COMMENT(exp, pszComment)
  52. #define VERIFY(exp) ((void)(exp))
  53. #define VERIFY_RESULT(exp1, exp2) ((void)(exp))
  54. #define DEBUG_ReportOleError(hres)
  55. #define DBWIN(psz)
  56. #define FAIL(pszComment)
  57. #define CHECK_POINTER(val)
  58. #define THIS_FILE __FILE__
  59. #endif
  60. #define ZERO_STRUCTURE(foo) ClearMemory(&foo, sizeof(foo))
  61. #define ClearMemory(p, cb) memset(p, 0, cb)