Global.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. #ifndef _DEBUG
  36. #undef DebugAssert
  37. #define DebugAssert(p) ((void)0)
  38. #define DebugCheck(p) p
  39. #define DebugFail
  40. #else // ifndef _DEBUG
  41. #define DebugCheck(p) { bool __CHECK_RESULT__ = (p); DebugAssert(__CHECK_RESULT__); }
  42. #define DebugFail DebugAssert(false)
  43. #endif // ifndef _DEBUG
  44. //---------------------------------------------------------------------------
  45. #define DebugAlwaysTrue(p) (p)
  46. #define DebugAlwaysFalse(p) (p)
  47. #define DebugNotNull(P) P
  48. #define DebugUsedParam(p) ((&p) == (&p))
  49. //---------------------------------------------------------------------------
  50. #endif