sparrow ..
Loading...
Searching...
No Matches
config.hpp
Go to the documentation of this file.
1// Copyright 2024 Man Group Operations Limited
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#pragma once
16
17#if defined(__apple_build_version__)
18# define COMPILING_WITH_APPLE_CLANG 1
19#else
20# define COMPILING_WITH_APPLE_CLANG 0
21#endif
22
23#if defined(_LIBCPP_VERSION) && _LIBCPP_VERSION < 170000
24# define USING_LIBCPP_PRE_17 1
25#else
26# define USING_LIBCPP_PRE_17 0
27#endif
28
29#if defined(_WIN32)
30# if defined(SPARROW_STATIC_LIB)
31# define SPARROW_API
32# elif defined(SPARROW_EXPORTS)
33# define SPARROW_API __declspec(dllexport)
34# else
35# define SPARROW_API __declspec(dllimport)
36# endif
37#else
38# define SPARROW_API __attribute__((visibility("default")))
39#endif
40
41[[nodiscard]] consteval bool is_apple_compiler()
42{
43 return static_cast<bool>(COMPILING_WITH_APPLE_CLANG);
44}
45
46// If using gcc versionn < 12, we define the constexpr keyword to be empty.
47#if defined(__GNUC__) && __GNUC__ < 12
48# define SPARROW_CONSTEXPR_GCC_11 inline
49#else
50# define SPARROW_CONSTEXPR_GCC_11 constexpr
51#endif
52
53#if (!defined(__clang__) && defined(__GNUC__))
54# if (__GNUC__ < 12 && __GNUC_MINOR__ < 3)
55# define SPARROW_GCC_11_2_WORKAROUND 1
56# endif
57#endif
58
59// If using clang or apple-clang version < 18 or clang 18 on Android, we define the constexpr keyword to be
60// "inline".
61#if defined(__clang__) && ((__clang_major__ < 18) || (__clang_major__ == 18 && defined(__ANDROID__)))
62# define SPARROW_CONSTEXPR_CLANG inline
63#else
64# define SPARROW_CONSTEXPR_CLANG constexpr
65#endif
66
67#if defined(__EMSCRIPTEN__) && defined(__CLANG_REPL__)
68# include <clang/Interpreter/CppInterOp.h>
69
70# ifndef SPARROW_USE_DATE_POLYFILL
71# define SPARROW_USE_DATE_POLYFILL 1
72# endif
73
74# ifndef HALF_ERRHANDLING_THROWS
75# define HALF_ERRHANDLING_THROWS 1
76# endif
77
78static bool _sparrow_loaded = []()
79{
80 Cpp::LoadLibrary("/lib/libsparrow.so", false);
81 return true;
82}();
83#endif
consteval bool is_apple_compiler()
Definition config.hpp:41
#define COMPILING_WITH_APPLE_CLANG
Definition config.hpp:20