EnTT: src/entt/config/config.h Source File

EnTT 3.16.0

Loading...
Searching...
No Matches
config.h
1#ifndef ENTT_CONFIG_CONFIG_H
2#define ENTT_CONFIG_CONFIG_H
3
4#include "version.h"
5
6// NOLINTBEGIN(cppcoreguidelines-macro-usage)
7
8#if defined(__cpp_exceptions) && !defined(ENTT_NOEXCEPTION)
9# define ENTT_CONSTEXPR
10# define ENTT_THROW throw
11# define ENTT_TRY try
12# define ENTT_CATCH catch(...)
13#else
14# define ENTT_CONSTEXPR constexpr // use only with throwing functions (waiting for C++20)
15# define ENTT_THROW
16# define ENTT_TRY if(true)
17# define ENTT_CATCH if(false)
18#endif
19
20#if __has_include(<version>)
21# include <version>
22#
23# if defined(__cpp_consteval)
24# define ENTT_CONSTEVAL consteval
25# endif
26#endif
27
28#ifndef ENTT_CONSTEVAL
29# define ENTT_CONSTEVAL constexpr
30#endif
31
32#ifdef ENTT_USE_ATOMIC
33# include <atomic>
34# define ENTT_MAYBE_ATOMIC(Type) std::atomic<Type>
35#else
36# define ENTT_MAYBE_ATOMIC(Type) Type
37#endif
38
39#ifndef ENTT_ID_TYPE
40# include <cstdint>
41# define ENTT_ID_TYPE std::uint32_t
42#else
43# include <cstdint> // provides coverage for types in the std namespace
44#endif
45
46#ifndef ENTT_SPARSE_PAGE
47# define ENTT_SPARSE_PAGE 4096
48#endif
49
50#ifndef ENTT_PACKED_PAGE
51# define ENTT_PACKED_PAGE 1024
52#endif
53
54#ifdef ENTT_DISABLE_ASSERT
55# undef ENTT_ASSERT
56# define ENTT_ASSERT(condition, msg) (void(0))
57#elif !defined ENTT_ASSERT
58# include <cassert>
59# define ENTT_ASSERT(condition, msg) assert(((condition) && (msg)))
60#endif
61
62#ifdef ENTT_DISABLE_ASSERT
63# undef ENTT_ASSERT_CONSTEXPR
64# define ENTT_ASSERT_CONSTEXPR(condition, msg) (void(0))
65#elif !defined ENTT_ASSERT_CONSTEXPR
66# define ENTT_ASSERT_CONSTEXPR(condition, msg) ENTT_ASSERT(condition, msg)
67#endif
68
69#define ENTT_FAIL(msg) ENTT_ASSERT(false, msg);
70
71#ifdef ENTT_NO_ETO
72# define ENTT_ETO_TYPE(Type) void
73#else
74# define ENTT_ETO_TYPE(Type) Type
75#endif
76
77#ifdef ENTT_NO_MIXIN
78# define ENTT_STORAGE(Mixin, ...) __VA_ARGS__
79#else
80# define ENTT_STORAGE(Mixin, ...) Mixin<__VA_ARGS__>
81#endif
82
83#ifdef ENTT_STANDARD_CPP
84# define ENTT_NONSTD false
85#else
86# define ENTT_NONSTD true
87# if defined __clang__ || defined __GNUC__
88# define ENTT_PRETTY_FUNCTION __PRETTY_FUNCTION__
89# define ENTT_PRETTY_FUNCTION_PREFIX '='
90# define ENTT_PRETTY_FUNCTION_SUFFIX ']'
91# elif defined _MSC_VER
92# define ENTT_PRETTY_FUNCTION __FUNCSIG__
93# define ENTT_PRETTY_FUNCTION_PREFIX '<'
94# define ENTT_PRETTY_FUNCTION_SUFFIX '>'
95# endif
96#endif
97
98#ifndef ENTT_EXPORT
99# if defined _WIN32 || defined __CYGWIN__ || defined _MSC_VER
100# define ENTT_EXPORT __declspec(dllexport)
101# define ENTT_IMPORT __declspec(dllimport)
102# define ENTT_HIDDEN
103# elif defined __GNUC__ && __GNUC__ >= 4
104# define ENTT_EXPORT __attribute__((visibility("default")))
105# define ENTT_IMPORT __attribute__((visibility("default")))
106# define ENTT_HIDDEN __attribute__((visibility("hidden")))
107# else /* Unsupported compiler */
108# define ENTT_EXPORT
109# define ENTT_IMPORT
110# define ENTT_HIDDEN
111# endif
112#endif
113
114#ifndef ENTT_API
115# if defined ENTT_API_EXPORT
116# define ENTT_API ENTT_EXPORT
117# elif defined ENTT_API_IMPORT
118# define ENTT_API ENTT_IMPORT
119# else /* No API */
120# define ENTT_API
121# endif
122#endif
123
124#if defined _MSC_VER
125# pragma detect_mismatch("entt.version", ENTT_VERSION)
126# pragma detect_mismatch("entt.noexcept", ENTT_XSTR(ENTT_TRY))
127# pragma detect_mismatch("entt.id", ENTT_XSTR(ENTT_ID_TYPE))
128# pragma detect_mismatch("entt.nonstd", ENTT_XSTR(ENTT_NONSTD))
129#endif
130
131// NOLINTEND(cppcoreguidelines-macro-usage)
132
133#endif