Cthulhu  0.2.10
Cthulhu compiler collection
cxx_compat.h
Go to the documentation of this file.
1 // SPDX-License-Identifier: LGPL-3.0-only
2 #pragma once
3 
4 // use _MSVC_LANG to detect the c++ version on msvc
5 // otherwise we would force other projects consuming this header
6 // to specify /Zc:__cplusplus
7 #if defined(_MSVC_LANG)
8 # define CT_CPLUSPLUS _MSVC_LANG
9 #elif defined(__cplusplus)
10 # define CT_CPLUSPLUS __cplusplus
11 #else
12 # define CT_CPLUSPLUS 0
13 #endif
14 
15 #if CT_CPLUSPLUS >= 202002L
16 # include <version>
17 #endif
18 
19 #if __cpp_lib_unreachable >= 202202L
20 # include <utility>
21 #endif
22 
25 #if defined(__has_cpp_attribute)
26 # define CT_HAS_CXX_ATTRIBUTE(x) __has_cpp_attribute(x)
27 #else
28 # define CT_HAS_CXX_ATTRIBUTE(x) 0
29 #endif
30 
31 #if CT_CPLUSPLUS >= 202002L
32 # define CTX_TEST(name, ...) static_assert([] { __VA_ARGS__ }(), name)
33 # define CTX_CONSTEXPR constexpr
34 # define CTX_IMPL(...) __VA_ARGS__
35 #else
36 # define CTX_TEST(name)
37 # define CTX_CONSTEXPR
38 # define CTX_IMPL(...)
39 #endif