mimic++ v10.0.1
Loading...
Searching...
No Matches
Config.hpp
Go to the documentation of this file.
1// Copyright Dominic (DNKpp) Koepke 2024-2026.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at
4// https://www.boost.org/LICENSE_1_0.txt)
5
6#ifndef MIMICPP_CONFIG_CONFIG_HPP
7#define MIMICPP_CONFIG_CONFIG_HPP
8
9#pragma once
10
11#ifndef MIMICPP_DETAIL_IS_MODULE
12 #include <cstdint>
13 #include <version>
14#endif
15
16#ifdef MIMICPP_DETAIL_IS_MODULE
17 #define MIMICPP_DETAIL_MODULE_EXPORT export
18#else
19 #define MIMICPP_DETAIL_MODULE_EXPORT
20#endif
21
22#if INTPTR_MAX < INT64_MAX
23 #define MIMICPP_DETAIL_IS_32BIT 1
24#endif
25
26#ifdef __GNUC__
27 #ifdef __clang__
28 #define MIMICPP_DETAIL_IS_CLANG 1
29 #ifdef __apple_build_version__
30 #define MIMICPP_DETAIL_IS_APPLE_CLANG 1
31 #endif
32 #else
33 #define MIMICPP_DETAIL_IS_GCC 1
34 #endif
35#endif
36
37#ifdef _LIBCPP_VERSION
38 #define MIMICPP_DETAIL_USES_LIBCXX 1
39#endif
40
41#ifdef _WIN32
42 #define MIMICPP_DETAIL_IS_WINDOWS 1
43#endif
44
45#ifdef _MSC_VER
46 #ifdef __clang__
47 #define MIMICPP_DETAIL_IS_CLANG_CL 1
48 #else
49 #define MIMICPP_DETAIL_IS_MSVC 1
50 #endif
51#endif
52
53#ifndef MIMICPP_ASSERT
54 #define MIMICPP_ASSERT(condition, msg) (void(0))
55#endif
56
57// clang-format off
58// Prevent number from getting decorated with '.
59#if 201907L <= __cpp_lib_constexpr_string
60 // clang-format on
61 #define MIMICPP_DETAIL_CONSTEXPR_STRING constexpr
62#else
63 #define MIMICPP_DETAIL_CONSTEXPR_STRING inline
64#endif
65
66// clang-format off
67// Prevent number from getting decorated with '.
68#if 201907L <= __cpp_lib_constexpr_vector
69 // clang-format on
70 #define MIMICPP_DETAIL_CONSTEXPR_VECTOR constexpr
71#else
72 #define MIMICPP_DETAIL_CONSTEXPR_VECTOR inline
73#endif
74
75// Requires constexpr vector and constexpr optional
76// clang-format off
77// Prevent number from getting decorated with '.
78#if 201907L <= __cpp_lib_constexpr_vector \
79 && 202106L <= __cpp_lib_optional
80 // clang-format on
81
82 // std::optional is not fully constexpr on libc++ < 19.
83 // clang-format off
84 // Prevent number from getting decorated with '.
85 #if !MIMICPP_DETAIL_USES_LIBCXX \
86 || 190000 <= _LIBCPP_VERSION
87 // clang-format on
88 #define MIMICPP_DETAIL_CONSTEXPR_PRETTY_TYPES constexpr
89 #endif
90#endif
91
92#ifndef MIMICPP_DETAIL_CONSTEXPR_PRETTY_TYPES
93 #define MIMICPP_DETAIL_CONSTEXPR_PRETTY_TYPES inline
94#endif
95
96// gcc 10 requires a workaround, due to some ambiguities.
97// see: https://github.com/DNKpp/mimicpp/issues/151
98#if MIMICPP_DETAIL_IS_GCC \
99 && __GNUC__ <= 10
100 #define MIMICPP_DETAIL_STD_GET_WORKAROUND 1
101#endif
102
103#ifdef __cpp_lib_source_location
104 #define MIMICPP_DETAIL_HAS_SOURCE_LOCATION 1
105#endif
106
107#endif