1
0

Global.h 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. UnicodeString NormalizeString(const UnicodeString & S);
  15. UnicodeString DenormalizeString(const UnicodeString & S);
  16. #define DateTimeToVariant(DATETIME) static_cast<long double>(static_cast<double>(DATETIME))
  17. //---------------------------------------------------------------------------
  18. class TGuard
  19. {
  20. public:
  21. __fastcall TGuard(TCriticalSection * ACriticalSection);
  22. __fastcall ~TGuard();
  23. private:
  24. TCriticalSection * FCriticalSection;
  25. };
  26. //---------------------------------------------------------------------------
  27. class TUnguard
  28. {
  29. public:
  30. __fastcall TUnguard(TCriticalSection * ACriticalSection);
  31. __fastcall ~TUnguard();
  32. private:
  33. TCriticalSection * FCriticalSection;
  34. };
  35. //---------------------------------------------------------------------------
  36. #ifdef __clang__
  37. #define CLANG_INITIALIZE(V) = (V)
  38. #define NORETURN [[noreturn]]
  39. #define UNREACHABLE_AFTER_NORETURN(STATEMENT)
  40. #define EXCEPT noexcept(false)
  41. #else
  42. #define CLANG_INITIALIZE(V)
  43. #define NORETURN
  44. #define UNREACHABLE_AFTER_NORETURN(STATEMENT) STATEMENT
  45. #define EXCEPT
  46. #endif
  47. //---------------------------------------------------------------------------
  48. //---------------------------------------------------------------------------
  49. #include <assert.h>
  50. // Mere write to constant null pointer would be optimized out by Clang, so we need to calculate one
  51. #define ACCESS_VIOLATION_TEST { (*strchr(const_cast<char *>(""), 'a')) = 0; }
  52. #if defined(_DEBUG) && !defined(DESIGN_ONLY)
  53. #define DODEBUGGING
  54. #endif
  55. #ifndef DODEBUGGING
  56. #define DebugAssert(p) ((void)0)
  57. #define DebugCheck(p) (p)
  58. #define DebugCheckNotEqual(p, e) (p)
  59. #define DebugFail()
  60. #else // ifndef DODEBUGGING
  61. void __fastcall DoAssert(const wchar_t * Message, const wchar_t * Filename, int LineNumber);
  62. #define DebugAssert(p) ((p) ? (void)0 : DoAssert(TEXT(#p), TEXT(__FILE__), __LINE__))
  63. #define DebugCheck(p) { bool __CHECK_RESULT__ = (p); DebugAssert(__CHECK_RESULT__); }
  64. #define DebugCheckNotEqual(p, e) DebugCheck((p) != e)
  65. #define DebugFail() DebugAssert(false)
  66. #endif // ifndef DODEBUGGING
  67. //---------------------------------------------------------------------------
  68. #define DebugAlwaysTrue(p) (p)
  69. #define DebugAlwaysFalse(p) (p)
  70. #define DebugNotNull(p) (p)
  71. #define TraceInitPtr(p) (p)
  72. #define TraceInitStr(p) (p)
  73. #define DebugUsedParam2(p1, p2) (static_cast<const void *>(&p1) == static_cast<const void *>(&p2))
  74. #define DebugUsedParam(p) DebugUsedParam2(p, p)
  75. #define DebugUsedArg(p)
  76. //---------------------------------------------------------------------------
  77. #endif