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.

74 lines
2.5 KiB

  1. /************************************************************************/
  2. /* */
  3. /* ASSERT.H -- Assertion Macros */
  4. /* */
  5. /************************************************************************/
  6. /* Author: */
  7. /* Copyright: */
  8. /************************************************************************/
  9. /* File Description: */
  10. /* */
  11. /* */
  12. /************************************************************************/
  13. /* Revision History: */
  14. /* */
  15. /* */
  16. /************************************************************************/
  17. /* ------------------------------------------------------------ */
  18. /* */
  19. /* ------------------------------------------------------------ */
  20. #ifndef _ASSERT_H_
  21. #define _ASSERT_H_
  22. //#include <dbgflags.h>
  23. //extern int dwDebugFlags;
  24. /* ------------------------------------------------------------ */
  25. /* Debug Function Prototypes and Definitions */
  26. /* ------------------------------------------------------------ */
  27. VOID PASCAL PrintFailedAssertion(int, char *);
  28. #ifdef DEBUG
  29. #define SetFile() \
  30. static char __szSrcFile[] = __FILE__;
  31. #else
  32. #define SetFile()
  33. #endif
  34. /* ------------------------------------------------------------ */
  35. /* Debug Macros */
  36. /* ------------------------------------------------------------ */
  37. #ifdef DEBUG
  38. #define break() _asm { _asm int 3 }
  39. #define assert(cond) \
  40. if (!(cond)) {\
  41. PrintFailedAssertion(__LINE__,__szSrcFile);\
  42. }
  43. #else
  44. #define break()
  45. #define assert(cond)
  46. #endif
  47. #endif // _ASSERT_H_
  48. static VOID PASCAL PrintFailedAssertion(int iLine, char * szFileName)
  49. {
  50. char achLocal[60];
  51. wsprintf(achLocal, "Assertion failed at line %d in file ", iLine);
  52. OutputDebugString(achLocal);
  53. OutputDebugString(szFileName);
  54. OutputDebugString("\012\015");
  55. }