14#define LAGRANGE_TARGET_OS(X) LAGRANGE_TARGET_OS_PRIVATE_DEFINITION_##X()
16#if defined(_WIN32) || defined(_WIN64)
17 #define LAGRANGE_TARGET_OS_PRIVATE_DEFINITION_WINDOWS() 1
18 #define LAGRANGE_TARGET_OS_PRIVATE_DEFINITION_LINUX() 0
19 #define LAGRANGE_TARGET_OS_PRIVATE_DEFINITION_APPLE() 0
20 #define LAGRANGE_TARGET_OS_PRIVATE_DEFINITION_WASM() 0
21#elif defined(__APPLE__)
22 #define LAGRANGE_TARGET_OS_PRIVATE_DEFINITION_WINDOWS() 0
23 #define LAGRANGE_TARGET_OS_PRIVATE_DEFINITION_APPLE() 1
24 #define LAGRANGE_TARGET_OS_PRIVATE_DEFINITION_LINUX() 0
25 #define LAGRANGE_TARGET_OS_PRIVATE_DEFINITION_WASM() 0
26#elif defined(__linux__)
27 #define LAGRANGE_TARGET_OS_PRIVATE_DEFINITION_WINDOWS() 0
28 #define LAGRANGE_TARGET_OS_PRIVATE_DEFINITION_APPLE() 0
29 #define LAGRANGE_TARGET_OS_PRIVATE_DEFINITION_LINUX() 1
30 #define LAGRANGE_TARGET_OS_PRIVATE_DEFINITION_WASM() 0
31#elif defined(__wasm__)
32 #define LAGRANGE_TARGET_OS_PRIVATE_DEFINITION_WINDOWS() 0
33 #define LAGRANGE_TARGET_OS_PRIVATE_DEFINITION_APPLE() 0
34 #define LAGRANGE_TARGET_OS_PRIVATE_DEFINITION_LINUX() 0
35 #define LAGRANGE_TARGET_OS_PRIVATE_DEFINITION_WASM() 1
37 #error "Platform not supported"
40#define LAGRANGE_TARGET_COMPILER(X) LAGRANGE_TARGET_COMPILER_PRIVATE_DEFINITION_##X()
42#if defined(__EMSCRIPTEN__)
43 #define LAGRANGE_TARGET_COMPILER_PRIVATE_DEFINITION_MSVC() 0
44 #define LAGRANGE_TARGET_COMPILER_PRIVATE_DEFINITION_CYGWIN() 0
45 #define LAGRANGE_TARGET_COMPILER_PRIVATE_DEFINITION_CLANG() 0
46 #define LAGRANGE_TARGET_COMPILER_PRIVATE_DEFINITION_GCC() 0
47 #define LAGRANGE_TARGET_COMPILER_PRIVATE_DEFINITION_EMSCRIPTEN() 1
48#elif defined(_MSC_VER)
49 #define LAGRANGE_TARGET_COMPILER_PRIVATE_DEFINITION_MSVC() 1
50 #define LAGRANGE_TARGET_COMPILER_PRIVATE_DEFINITION_CYGWIN() 0
51 #define LAGRANGE_TARGET_COMPILER_PRIVATE_DEFINITION_CLANG() 0
52 #define LAGRANGE_TARGET_COMPILER_PRIVATE_DEFINITION_GCC() 0
53 #define LAGRANGE_TARGET_COMPILER_PRIVATE_DEFINITION_EMSCRIPTEN() 0
54#elif defined(__CYGWIN__)
55 #define LAGRANGE_TARGET_COMPILER_PRIVATE_DEFINITION_MSVC() 0
56 #define LAGRANGE_TARGET_COMPILER_PRIVATE_DEFINITION_CYGWIN() 1
57 #define LAGRANGE_TARGET_COMPILER_PRIVATE_DEFINITION_CLANG() 0
58 #define LAGRANGE_TARGET_COMPILER_PRIVATE_DEFINITION_GCC() 0
59 #define LAGRANGE_TARGET_COMPILER_PRIVATE_DEFINITION_EMSCRIPTEN() 0
60#elif defined(__clang__)
61 #define LAGRANGE_TARGET_COMPILER_PRIVATE_DEFINITION_MSVC() 0
62 #define LAGRANGE_TARGET_COMPILER_PRIVATE_DEFINITION_CYGWIN() 0
63 #define LAGRANGE_TARGET_COMPILER_PRIVATE_DEFINITION_CLANG() 1
64 #define LAGRANGE_TARGET_COMPILER_PRIVATE_DEFINITION_GCC() 0
65 #define LAGRANGE_TARGET_COMPILER_PRIVATE_DEFINITION_EMSCRIPTEN() 0
66#elif defined(__GNUC__)
67 #define LAGRANGE_TARGET_COMPILER_PRIVATE_DEFINITION_MSVC() 0
68 #define LAGRANGE_TARGET_COMPILER_PRIVATE_DEFINITION_CYGWIN() 0
69 #define LAGRANGE_TARGET_COMPILER_PRIVATE_DEFINITION_CLANG() 0
70 #define LAGRANGE_TARGET_COMPILER_PRIVATE_DEFINITION_GCC() 1
71 #define LAGRANGE_TARGET_COMPILER_PRIVATE_DEFINITION_EMSCRIPTEN() 0
73 #error "Compiler not supported"
76#define LAGRANGE_TARGET_PLATFORM(X) LAGRANGE_TARGET_PLATFORM_PRIVATE_DEFINITION_##X()
78#if defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64) || \
79 defined(_M_X64) || defined(_M_AMD64)
80 #define LAGRANGE_TARGET_PLATFORM_PRIVATE_DEFINITION_x86_64() 1
81 #define LAGRANGE_TARGET_PLATFORM_PRIVATE_DEFINITION_arm64() 0
82#elif defined(__aarch64__) || defined(_M_ARM64) || defined(_M_ARM64EC)
83 #define LAGRANGE_TARGET_PLATFORM_PRIVATE_DEFINITION_x86_64() 0
84 #define LAGRANGE_TARGET_PLATFORM_PRIVATE_DEFINITION_arm64() 1
86 #define LAGRANGE_TARGET_PLATFORM_PRIVATE_DEFINITION_x86_64() 0
87 #define LAGRANGE_TARGET_PLATFORM_PRIVATE_DEFINITION_arm64() 0
90#if defined(__wasm32__)
91 #define LAGRANGE_TARGET_PLATFORM_PRIVATE_DEFINITION_wasm32() 1
92 #define LAGRANGE_TARGET_PLATFORM_PRIVATE_DEFINITION_wasm64() 0
93#elif defined(__wasm64__)
94 #define LAGRANGE_TARGET_PLATFORM_PRIVATE_DEFINITION_wasm32() 0
95 #define LAGRANGE_TARGET_PLATFORM_PRIVATE_DEFINITION_wasm64() 1
97 #define LAGRANGE_TARGET_PLATFORM_PRIVATE_DEFINITION_wasm32() 0
98 #define LAGRANGE_TARGET_PLATFORM_PRIVATE_DEFINITION_wasm64() 0
102 LAGRANGE_TARGET_PLATFORM(x86_64) || LAGRANGE_TARGET_PLATFORM(arm64) || \
103 LAGRANGE_TARGET_PLATFORM(wasm32) || LAGRANGE_TARGET_PLATFORM(wasm64))
104 #error "Unexpected target platform setup"
107#define LAGRANGE_TARGET_FEATURE(X) LAGRANGE_TARGET_FEATURE_PRIVATE_DEFINITION_##X()
109#if __clang__ && !__INTEL_COMPILER
110 #define LAGRANGE_ENABLE_RTTI __has_feature(cxx_rtti)
111#elif defined(_CPPRTTI)
112 #define LAGRANGE_ENABLE_RTTI 1
114 #define LAGRANGE_ENABLE_RTTI (__GXX_RTTI || __RTTI || __INTEL_RTTI__)
117#if LAGRANGE_ENABLE_RTTI
118 #define LAGRANGE_TARGET_FEATURE_PRIVATE_DEFINITION_RTTI() 1
120 #define LAGRANGE_TARGET_FEATURE_PRIVATE_DEFINITION_RTTI() 0