Global.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. //---------------------------------------------------------------------------
  2. #ifndef GlobalH
  3. #define GlobalH
  4. //---------------------------------------------------------------------------
  5. #define FORMAT(S, F) Format(S, ARRAYOFCONST(F))
  6. #define FMTLOAD(I, F) FmtLoadStr(I, ARRAYOFCONST(F))
  7. #define LENOF(x) ( (sizeof((x))) / (sizeof(*(x))))
  8. #define FLAGSET(SET, FLAG) (((SET) & (FLAG)) == (FLAG))
  9. #define FLAGCLEAR(SET, FLAG) (((SET) & (FLAG)) == 0)
  10. #define FLAGMASK(ENABLE, FLAG) ((ENABLE) ? (FLAG) : 0)
  11. //---------------------------------------------------------------------------
  12. #include <System.SyncObjs.hpp>
  13. //---------------------------------------------------------------------------
  14. class TGuard
  15. {
  16. public:
  17. __fastcall TGuard(TCriticalSection * ACriticalSection);
  18. __fastcall ~TGuard();
  19. private:
  20. TCriticalSection * FCriticalSection;
  21. };
  22. //---------------------------------------------------------------------------
  23. class TUnguard
  24. {
  25. public:
  26. __fastcall TUnguard(TCriticalSection * ACriticalSection);
  27. __fastcall ~TUnguard();
  28. private:
  29. TCriticalSection * FCriticalSection;
  30. };
  31. //---------------------------------------------------------------------------
  32. //---------------------------------------------------------------------------
  33. #include <assert.h>
  34. #define ACCESS_VIOLATION_TEST { (*((int*)NULL)) = 0; }
  35. #if !defined(_DEBUG) || defined(DESIGN_ONLY)
  36. #define DebugAssert(p) ((void)0)
  37. #define DebugCheck(p) (p)
  38. #define DebugFail()
  39. #else // if !defined(_DEBUG) || defined(DESIGN_ONLY)
  40. void __fastcall DoAssert(wchar_t * Message, wchar_t * Filename, int LineNumber);
  41. #define DebugAssert(p) ((p) ? (void)0 : DoAssert(TEXT(#p), TEXT(__FILE__), __LINE__))
  42. #define DebugCheck(p) { bool __CHECK_RESULT__ = (p); DebugAssert(__CHECK_RESULT__); }
  43. #define DebugFail() DebugAssert(false)
  44. #endif // if !defined(_DEBUG) || defined(DESIGN_ONLY)
  45. //---------------------------------------------------------------------------
  46. #define DebugAlwaysTrue(p) (p)
  47. #define DebugAlwaysFalse(p) (p)
  48. #define DebugNotNull(p) (p)
  49. #define TraceInitPtr(p) (p)
  50. #define TraceInitStr(p) (p)
  51. #define DebugUsedParam(p) ((&p) == (&p))
  52. #define DebugUsedArg(p)
  53. //---------------------------------------------------------------------------
  54. #endif