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.

109 lines
3.8 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corp., 1991 **/
  4. /**********************************************************************/
  5. /*
  6. UIAssert.hxx
  7. UI environment independent assertion/logging routines
  8. See also "UITrace.HXX" and "Dbgstr.HXX."
  9. Usage:
  10. ASSERT(exp) Evaluates its argument. If "exp" evals to
  11. FALSE, then the app will terminate, naming
  12. the file name and line number of the assertion
  13. in the source.
  14. UIASSERT(exp) Synonym for ASSERT.
  15. ASSERTSZ(exp, sz) As ASSERT, except will also print the message
  16. "sz" with the assertion message should it fail.
  17. REQUIRE(exp) As ASSERT, except that its expression is still
  18. evaluated in retail versions. (Other versions
  19. of ASSERT disappear completely in retail builds.)
  20. The ASSERT macros expect a symbol _FILENAME_DEFINED_ONCE, and will
  21. use the value of that symbol as the filename if found; otherwise,
  22. they will emit a new copy of the filename, using the ANSI C __FILE__
  23. macro. A client sourcefile may therefore define __FILENAME_DEFINED_ONCE
  24. in order to minimize the DGROUP footprint of a number of ASSERTs.
  25. FILE HISTORY:
  26. Johnl 15-Nov-1990 Converted from CAssert to general purpose
  27. Johnl 6-Dec-1990 Changed _FAR_ to _far in _assert prototype
  28. beng 30-Apr-1991 Made C-includable
  29. beng 05-Aug-1991 Made assertions occupy less dgroup; withdrew
  30. explicit heapchecking (which was crt
  31. dependent anyway)
  32. beng 17-Sep-1991 Removed additional consistency checks;
  33. rewrote to minimize dgroup footprint,
  34. check expression in-line
  35. beng 19-Sep-1991 Fixed my own over-cleverness
  36. beng 25-Sep-1991 Fixed bug in retail REQUIRE
  37. KeithMo 07-Oct-1991 Retail builds don't Glock.
  38. beng 16-Oct-1991 Helper fcns are C++. (C clients should use
  39. the standard runtime, anyway.)
  40. beng 08-Mar-1992 Unicode fixes
  41. beng 25-Mar-1992 Further Unicode work (filename is SBCS)
  42. KeithMo 21-Aug-1992 ASSERTSZ must take aa SBCS message now. Sorry.
  43. */
  44. #ifndef _UIASSERT_HXX_
  45. #define _UIASSERT_HXX_
  46. extern DLL_BASED VOID UIAssertHlp( const CHAR* pszFileName, UINT nLine );
  47. extern DLL_BASED VOID UIAssertHlp( const CHAR* pszMessage,
  48. const CHAR* pszFileName, UINT nLine );
  49. #ifdef ASSERT
  50. #undef ASSERT
  51. #endif
  52. #ifdef UIASSERT
  53. #undef UIASSERT
  54. #endif
  55. #ifdef ASSERTSZ
  56. #undef ASSERTSZ
  57. #endif
  58. #ifdef REQUIRE
  59. #undef REQUIRE
  60. #endif
  61. #if defined(DEBUG)
  62. # if defined(_FILENAME_DEFINED_ONCE)
  63. # define ASSERT(exp) \
  64. { if (!(exp)) ::UIAssertHlp(_FILENAME_DEFINED_ONCE, __LINE__); }
  65. # define ASSERTSZ(exp, sz) \
  66. { if (!(exp)) ::UIAssertHlp((sz), _FILENAME_DEFINED_ONCE, __LINE__); }
  67. # else
  68. # define ASSERT(exp) \
  69. { if (!(exp)) ::UIAssertHlp(__FILE__, __LINE__); }
  70. # define ASSERTSZ(exp, sz) \
  71. { if (!(exp)) ::UIAssertHlp((sz), __FILE__, __LINE__); }
  72. # endif
  73. # define UIASSERT(exp) ASSERT(exp)
  74. # define REQUIRE(exp) ASSERT(exp)
  75. #else // !DEBUG
  76. # define ASSERT(exp) { ; }
  77. # define UIASSERT(exp) { ; }
  78. # define ASSERTSZ(exp, sz) { ; }
  79. # define REQUIRE(exp) { (exp); }
  80. #endif // DEBUG
  81. #endif // _UIASSERT_HXX_