sparrow-extensions 0.1.0
Extension types for the sparrow library
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// DLL export/import macros for Windows
18#if defined(_WIN32)
19# if defined(SPARROW_EXTENSIONS_STATIC_LIB)
20# define SPARROW_EXTENSIONS_API
21# elif defined(SPARROW_EXTENSIONS_EXPORTS)
22# define SPARROW_EXTENSIONS_API __declspec(dllexport)
23# else
24# define SPARROW_EXTENSIONS_API __declspec(dllimport)
25# endif
26#else
27# define SPARROW_EXTENSIONS_API __attribute__((visibility("default")))
28#endif
29
30// If using gcc version < 12, we define the constexpr keyword to be empty.
31#if defined(__GNUC__) && __GNUC__ < 12
32# define SPARROW_EXTENSIONS_CONSTEXPR_GCC_11 inline
33#else
34# define SPARROW_EXTENSIONS_CONSTEXPR_GCC_11 constexpr
35#endif
36
37#if (!defined(__clang__) && defined(__GNUC__))
38# if (__GNUC__ < 12 && __GNUC_MINOR__ < 3)
39# define SPARROW_EXTENSIONS_GCC_11_2_WORKAROUND 1
40# endif
41#endif
42
43// If using clang or apple-clang version < 18 or clang 18 on Android, we define the constexpr keyword to be
44// "inline".
45#if defined(__clang__) && ((__clang_major__ < 18) || (__clang_major__ == 18 && defined(__ANDROID__)))
46# define SPARROW_EXTENSIONS_CONSTEXPR_CLANG inline
47#else
48# define SPARROW_EXTENSIONS_CONSTEXPR_CLANG constexpr
49#endif
50
51#if defined(__EMSCRIPTEN__) && defined(__CLANG_REPL__)
52# include <clang/Interpreter/CppInterOp.h>
53
54# ifndef SPARROW_EXTENSIONS_USE_DATE_POLYFILL
55# define SPARROW_EXTENSIONS_USE_DATE_POLYFILL 1
56# endif
57
58# ifndef HALF_ERRHANDLING_THROWS
59# define HALF_ERRHANDLING_THROWS 1
60# endif
61
62static bool _sparrow_loaded = []()
63{
64 Cpp::LoadLibrary("/lib/libsparrow-extensions.so", false);
65 return true;
66}();
67#endif