tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
attributes.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2
3#ifndef TETL_CONFIG_ATTRIBUTES_HPP
4#define TETL_CONFIG_ATTRIBUTES_HPP
5
6#if __has_attribute(always_inline)
7 #define TETL_ALWAYS_INLINE [[gnu::always_inline]]
8#elif defined(_MSC_VER)
9 #define TETL_ALWAYS_INLINE [[msvc::forceinline]]
10#else
11 #define TETL_ALWAYS_INLINE
12#endif
13
14#if __has_attribute(noinline)
15 #define TETL_NO_INLINE [[gnu::noinline]]
16#elif defined(_MSC_VER)
17 #define TETL_NO_INLINE [[msvc::noinline]]
18#else
19 #define TETL_NO_INLINE
20#endif
21
22#if __has_attribute(cold)
23 #define TETL_COLD [[gnu::cold]]
24#else
25 #define TETL_COLD
26#endif
27
28#if defined(__GNUC__) or defined(__clang__)
29 #define TETL_MAY_ALIAS [[gnu::may_alias]]
30#else
31 #define TETL_MAY_ALIAS
32#endif
33
34#if defined(_MSC_VER) and not defined(__clang__)
35 #define TETL_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]]
36#elif defined(_MSC_VER) and defined(__clang__) and (__clang_major__ >= 18)
37 #define TETL_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]]
38#elif defined(_MSC_VER) and defined(__clang__)
39 #define TETL_NO_UNIQUE_ADDRESS
40#else
41 #define TETL_NO_UNIQUE_ADDRESS [[no_unique_address]]
42#endif
43
44#if defined(__clang__)
45 #define TETL_TRIVIAL_ABI [[clang::trivial_abi]]
46#else
47 #define TETL_TRIVIAL_ABI
48#endif
49
50#endif // TETL_CONFIG_ATTRIBUTES_HPP