config.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #ifndef ENTT_CONFIG_CONFIG_H
  2. #define ENTT_CONFIG_CONFIG_H
  3. #include "version.h"
  4. #if defined(__cpp_exceptions) && !defined(ENTT_NOEXCEPTION)
  5. # define ENTT_CONSTEXPR
  6. # define ENTT_THROW throw
  7. # define ENTT_TRY try
  8. # define ENTT_CATCH catch(...)
  9. #else
  10. # define ENTT_CONSTEXPR constexpr // use only with throwing functions (waiting for C++20)
  11. # define ENTT_THROW
  12. # define ENTT_TRY if(true)
  13. # define ENTT_CATCH if(false)
  14. #endif
  15. #ifdef ENTT_USE_ATOMIC
  16. # include <atomic>
  17. # define ENTT_MAYBE_ATOMIC(Type) std::atomic<Type>
  18. #else
  19. # define ENTT_MAYBE_ATOMIC(Type) Type
  20. #endif
  21. #ifndef ENTT_ID_TYPE
  22. # include <cstdint>
  23. # define ENTT_ID_TYPE std::uint32_t
  24. #else
  25. # include <cstdint> // provides coverage for types in the std namespace
  26. #endif
  27. #ifndef ENTT_SPARSE_PAGE
  28. # define ENTT_SPARSE_PAGE 4096
  29. #endif
  30. #ifndef ENTT_PACKED_PAGE
  31. # define ENTT_PACKED_PAGE 1024
  32. #endif
  33. #ifdef ENTT_DISABLE_ASSERT
  34. # undef ENTT_ASSERT
  35. # define ENTT_ASSERT(condition, msg) (void(0))
  36. #elif !defined ENTT_ASSERT
  37. # include <cassert>
  38. # define ENTT_ASSERT(condition, msg) assert(condition)
  39. #endif
  40. #ifdef ENTT_DISABLE_ASSERT
  41. # undef ENTT_ASSERT_CONSTEXPR
  42. # define ENTT_ASSERT_CONSTEXPR(condition, msg) (void(0))
  43. #elif !defined ENTT_ASSERT_CONSTEXPR
  44. # define ENTT_ASSERT_CONSTEXPR(condition, msg) ENTT_ASSERT(condition, msg)
  45. #endif
  46. #define ENTT_FAIL(msg) ENTT_ASSERT(false, msg);
  47. #ifdef ENTT_NO_ETO
  48. # define ENTT_ETO_TYPE(Type) void
  49. #else
  50. # define ENTT_ETO_TYPE(Type) Type
  51. #endif
  52. #ifdef ENTT_STANDARD_CPP
  53. # define ENTT_NONSTD false
  54. #else
  55. # define ENTT_NONSTD true
  56. # if defined __clang__ || defined __GNUC__
  57. # define ENTT_PRETTY_FUNCTION __PRETTY_FUNCTION__
  58. # define ENTT_PRETTY_FUNCTION_PREFIX '='
  59. # define ENTT_PRETTY_FUNCTION_SUFFIX ']'
  60. # elif defined _MSC_VER
  61. # define ENTT_PRETTY_FUNCTION __FUNCSIG__
  62. # define ENTT_PRETTY_FUNCTION_PREFIX '<'
  63. # define ENTT_PRETTY_FUNCTION_SUFFIX '>'
  64. # endif
  65. #endif
  66. #if defined _MSC_VER
  67. # pragma detect_mismatch("entt.version", ENTT_VERSION)
  68. # pragma detect_mismatch("entt.noexcept", ENTT_XSTR(ENTT_TRY))
  69. # pragma detect_mismatch("entt.id", ENTT_XSTR(ENTT_ID_TYPE))
  70. # pragma detect_mismatch("entt.nonstd", ENTT_XSTR(ENTT_NONSTD))
  71. #endif
  72. #endif