C++ Essence Library
0.1.0
A Utility Library for Modern C++ Programming
Loading...
Searching...
No Matches
compat.hpp
1
/*
2
* Copyright (c) 2024 The RefValue Project
3
*
4
* Permission is hereby granted, free of charge, to any person obtaining a copy
5
* of this software and associated documentation files (the "Software"), to deal
6
* in the Software without restriction, including without limitation the rights
7
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
* copies of the Software, and to permit persons to whom the Software is
9
* furnished to do so, subject to the following conditions:
10
*
11
* The above copyright notice and this permission notice shall be included in
12
* all copies or substantial portions of the Software.
13
*
14
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
* THE SOFTWARE.
21
*/
22
23
#pragma once
24
25
// Directives for imports and exports are platform-specific not compiler-specific,
26
// so use WIN32 instead of _MSC_VER here to make it behave correctly and expectedly.
27
#ifdef _WIN32
28
#define ES_IMPORT __declspec(dllimport)
29
#define ES_EXPORT __declspec(dllexport)
30
#else
31
#define ES_IMPORT
32
#define ES_EXPORT __attribute__((visibility("default")))
33
#endif
34
35
#define ES_CONDITIONAL_COMMA_1 ,
36
#define ES_CONDITIONAL_COMMA_IMPL(x) ES_CONDITIONAL_COMMA_##x
37
#define ES_CONDITIONAL_COMMA(x) ES_CONDITIONAL_COMMA_IMPL(x)
38
39
#define ES_SELECT_THIRD_ARGUMENT(a, b, c, ...) c
40
#define ES_CONDITIONAL(condition, consequent, alternate) \
41
ES_SELECT_THIRD_ARGUMENT(ES_CONDITIONAL_COMMA(condition), consequent, alternate)
42
#define ES_API(x) ES_CONDITIONAL(ES_IS_##x##_IMPL, ES_IMPORT, ES_EXPORT)
43
44
#if __cplusplus >= 202002L
45
#define ES_HAS_CXX20 1
46
#else
47
#define ES_HAS_CXX20 0
48
#endif
49
50
#if defined(__GUNC__) || defined(__clang__)
51
#define ES_KEEP_ALIVE __attribute__((used))
52
#else
53
#define ES_KEEP_ALIVE
54
#endif
include
essence
compat.hpp
Generated by
1.12.0