CLI11  2.3.2
Macros.hpp
Go to the documentation of this file.
1 // Copyright (c) 2017-2023, University of Cincinnati, developed by Henry Schreiner
2 // under NSF AWARD 1414736 and by the respective contributors.
3 // All rights reserved.
4 //
5 // SPDX-License-Identifier: BSD-3-Clause
6 
7 #pragma once
8 
9 // [CLI11:macros_hpp:verbatim]
10 
11 // The following version macro is very similar to the one in pybind11
12 #if !(defined(_MSC_VER) && __cplusplus == 199711L) && !defined(__INTEL_COMPILER)
13 #if __cplusplus >= 201402L
14 #define CLI11_CPP14
15 #if __cplusplus >= 201703L
16 #define CLI11_CPP17
17 #if __cplusplus > 201703L
18 #define CLI11_CPP20
19 #endif
20 #endif
21 #endif
22 #elif defined(_MSC_VER) && __cplusplus == 199711L
23 // MSVC sets _MSVC_LANG rather than __cplusplus (supposedly until the standard is fully implemented)
24 // Unless you use the /Zc:__cplusplus flag on Visual Studio 2017 15.7 Preview 3 or newer
25 #if _MSVC_LANG >= 201402L
26 #define CLI11_CPP14
27 #if _MSVC_LANG > 201402L && _MSC_VER >= 1910
28 #define CLI11_CPP17
29 #if _MSVC_LANG > 201703L && _MSC_VER >= 1910
30 #define CLI11_CPP20
31 #endif
32 #endif
33 #endif
34 #endif
35 
36 #if defined(CLI11_CPP14)
37 #define CLI11_DEPRECATED(reason) [[deprecated(reason)]]
38 #elif defined(_MSC_VER)
39 #define CLI11_DEPRECATED(reason) __declspec(deprecated(reason))
40 #else
41 #define CLI11_DEPRECATED(reason) __attribute__((deprecated(reason)))
42 #endif
43 
44 // GCC < 10 doesn't ignore this in unevaluated contexts
45 #if !defined(CLI11_CPP17) || \
46  (defined(__GNUC__) && !defined(__llvm__) && !defined(__INTEL_COMPILER) && __GNUC__ < 10 && __GNUC__ > 4)
47 #define CLI11_NODISCARD
48 #else
49 #define CLI11_NODISCARD [[nodiscard]]
50 #endif
51 
53 #ifndef CLI11_USE_STATIC_RTTI
54 #if(defined(_HAS_STATIC_RTTI) && _HAS_STATIC_RTTI)
55 #define CLI11_USE_STATIC_RTTI 1
56 #elif defined(__cpp_rtti)
57 #if(defined(_CPPRTTI) && _CPPRTTI == 0)
58 #define CLI11_USE_STATIC_RTTI 1
59 #else
60 #define CLI11_USE_STATIC_RTTI 0
61 #endif
62 #elif(defined(__GCC_RTTI) && __GXX_RTTI)
63 #define CLI11_USE_STATIC_RTTI 0
64 #else
65 #define CLI11_USE_STATIC_RTTI 1
66 #endif
67 #endif
68 
70 #ifdef CLI11_COMPILE
71 #define CLI11_INLINE
72 #else
73 #define CLI11_INLINE inline
74 #endif
75 // [CLI11:macros_hpp:end]