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.

67 lines
2.1 KiB

  1. //=--------------------------------------------------------------------------=
  2. // Debug.H
  3. //=--------------------------------------------------------------------------=
  4. // Copyright 1995-1996 Microsoft Corporation. All Rights Reserved.
  5. //
  6. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
  7. // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
  8. // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  9. // PARTICULAR PURPOSE.
  10. //=--------------------------------------------------------------------------=
  11. //
  12. // contains the various macros and the like which are only useful in DEBUG
  13. // builds
  14. //
  15. #ifndef _DEBUG_H_
  16. //=---------------------------------------------------------------------------=
  17. // all the things required to handle our ASSERT mechanism
  18. //=---------------------------------------------------------------------------=
  19. //
  20. #if DEBUG
  21. // Function Prototypes
  22. //
  23. VOID DisplayAssert(LPSTR pszMsg, LPSTR pszAssert, LPSTR pszFile, UINT line);
  24. // Macros
  25. //
  26. // *** Include this macro at the top of any source file using *ASSERT*() macros ***
  27. //
  28. #define SZTHISFILE static char _szThisFile[] = __FILE__;
  29. // our versions of the ASSERT and FAIL macros.
  30. //
  31. #define ASSERT(fTest, szMsg) \
  32. if (!(fTest)) { \
  33. static char szMsgCode[] = szMsg; \
  34. static char szAssert[] = #fTest; \
  35. DisplayAssert(szMsgCode, szAssert, _szThisFile, __LINE__); \
  36. }
  37. #define FAIL(szMsg) \
  38. { static char szMsgCode[] = szMsg; \
  39. DisplayAssert(szMsgCode, "FAIL", _szThisFile, __LINE__); }
  40. // macro that checks a pointer for validity on input
  41. //
  42. #define CHECK_POINTER(val) if (!(val) || IsBadWritePtr((void *)(val), sizeof(void *))) return E_POINTER
  43. #else // DEBUG
  44. #define SZTHISFILE
  45. #define ASSERT(fTest, err)
  46. #define FAIL(err)
  47. #define CHECK_POINTER(val)
  48. #endif // DEBUG
  49. #define _DEBUG_H_
  50. #endif // _DEBUG_H_
  51.