Crypto++ 8.9 Free C++ class library of cryptographic schemes

config_cxx.h
Go to the documentation of this file.
1 // config_cxx.h - written and placed in public domain by Jeffrey Walton
2 // the bits that make up this source file are from the
3 // library's monolithic config.h.
4
5 /// \file config_cxx.h
6 /// \brief Library configuration file
7 /// \details <tt>config_cxx.h</tt> provides defines for C++ language and
8 /// runtime library
9 /// features.
10 /// \details <tt>config.h</tt> was split into components in May 2019 to better
11 /// integrate with Autoconf and its feature tests. The splitting occurred so
12 /// users could continue to include <tt>config.h</tt> while allowing Autoconf
13 /// to write new <tt>config_asm.h</tt> and new <tt>config_cxx.h</tt> using
14 /// its feature tests.
15 /// \note You should include <tt>config.h</tt> rather than <tt>config_cxx.h</tt>
16 /// directly.
17 /// \sa <A HREF="https://github.com/weidai11/cryptopp/issues/835">Issue 835,
18 /// Make config.h more autoconf friendly</A>,
19 /// <A HREF="https://www.cryptopp.com/wiki/Configure.sh">Configure.sh script</A>
20 /// on the Crypto++ wiki
21 /// \since Crypto++ 8.3
22
23 // Visual Studio began at VS2010, http://msdn.microsoft.com/en-us/library/hh567368%28v=vs.110%29.aspx
24 // and https://docs.microsoft.com/en-us/cpp/visual-cpp-language-conformance
25 // Intel, http://software.intel.com/en-us/articles/c0x-features-supported-by-intel-c-compiler
26 // GCC, http://gcc.gnu.org/projects/cxx0x.html
27 // Clang, http://clang.llvm.org/cxx_status.html
28
29 #ifndef CRYPTOPP_CONFIG_CXX_H
30 #define CRYPTOPP_CONFIG_CXX_H
31
32 #include "config_os.h"
33 #include "config_cpu.h"
34 #include "config_ver.h"
35
36 // https://github.com/weidai11/cryptopp/issues/960
37 #include <string>
38 #include <exception>
39
40 // You may need to force include a C++ header on Android when using STLPort
41 // to ensure _STLPORT_VERSION is defined
42 #if (defined(CRYPTOPP_MSC_VERSION) && CRYPTOPP_MSC_VERSION <= 1300) || \
43 defined(__MWERKS__) || \
44 (defined(_STLPORT_VERSION) && ((_STLPORT_VERSION < 0x450) || defined(_STLP_NO_UNCAUGHT_EXCEPT_SUPPORT)) || \
45 (__cplusplus >= 202002L))
46 #define CRYPTOPP_DISABLE_UNCAUGHT_EXCEPTION
47 #endif
48
49 // Ancient Crypto++ define, dating back to C++98.
50 #ifndef CRYPTOPP_DISABLE_UNCAUGHT_EXCEPTION
51 # define CRYPTOPP_UNCAUGHT_EXCEPTION_AVAILABLE 1
52 # define CRYPTOPP_CXX98_UNCAUGHT_EXCEPTION 1
53 #endif
54
55 // Compatibility with non-clang compilers.
56 #ifndef __has_feature
57 # define __has_feature(x) 0
58 #endif
59
60 // C++11 macro version, https://stackoverflow.com/q/7223991/608639
61 #if ((CRYPTOPP_MSC_VERSION >= 1600) || (__cplusplus >= 201103L)) && !defined(_STLPORT_VERSION)
62 # define CRYPTOPP_CXX11 1
63 #endif
64
65 // Hack ahead. Apple's standard library does not have C++'s unique_ptr in C++11.
66 // We can't test for unique_ptr directly because some of the non-Apple Clangs
67 // on OS X fail the same way. However, modern standard libraries have
68 // <forward_list>, so we test for it instead. Thanks to Jonathan Wakely for
69 // devising the clever test for modern/ancient versions. TODO: test under
70 // Xcode 3, where g++ is really g++.
71 #if defined(__APPLE__) && defined(__clang__)
72 # if !(defined(__has_include) && __has_include(<forward_list>))
73 # undef CRYPTOPP_CXX11
74 # endif
75 #endif
76
77 // C++14 macro version, https://stackoverflow.com/q/26089319/608639
78 #if defined(CRYPTOPP_CXX11) && !defined(CRYPTOPP_NO_CXX14)
79 # if ((CRYPTOPP_MSC_VERSION >= 1900) || (__cplusplus >= 201402L)) && !defined(_STLPORT_VERSION)
80 # define CRYPTOPP_CXX14 1
81 # endif
82 #endif
83
84 // C++17 macro version, https://stackoverflow.com/q/38456127/608639
85 #if defined(CRYPTOPP_CXX14) && !defined(CRYPTOPP_NO_CXX17)
86 # if ((CRYPTOPP_MSC_VERSION >= 1900) || (__cplusplus >= 201703L)) && !defined(_STLPORT_VERSION)
87 # define CRYPTOPP_CXX17 1
88 # endif
89 #endif
90
91 // ***************** C++11 and above ********************
92
93 #if defined(CRYPTOPP_CXX11)
94
95 // atomics: MS at VS2012 (17.00); GCC at 4.4; Clang at 3.1/3.2; Intel 13.0; SunCC 5.14.
96 #if (CRYPTOPP_MSC_VERSION >= 1700) || __has_feature(cxx_atomic) || \
97 (__INTEL_COMPILER >= 1300) || (CRYPTOPP_GCC_VERSION >= 40400) || (__SUNPRO_CC >= 0x5140)
98 # define CRYPTOPP_CXX11_ATOMIC 1
99 #endif // atomics
100
101 // synchronization: MS at VS2012 (17.00); GCC at 4.4; Clang at 3.3; Xcode 5.0; Intel 12.0; SunCC 5.13.
102 // TODO: verify Clang and Intel versions; find __has_feature(x) extension for Clang
103 #if (CRYPTOPP_MSC_VERSION >= 1700) || (CRYPTOPP_LLVM_CLANG_VERSION >= 30300) || \
104 (CRYPTOPP_APPLE_CLANG_VERSION >= 50000) || (__INTEL_COMPILER >= 1200) || \
105 (CRYPTOPP_GCC_VERSION >= 40400) || (__SUNPRO_CC >= 0x5130)
106 // Hack ahead. New GCC compilers like GCC 6 on AIX 7.0 or earlier as well as original MinGW
107 // don't have the synchronization gear. However, Wakely's test used for Apple does not work
108 // on the GCC/AIX combination. Another twist is we need other stuff from C++11,
109 // like no-except destructors. Dumping preprocessors shows the following may
110 // apply: http://stackoverflow.com/q/14191566/608639.
111 # include <cstddef>
112 # if !defined(__GLIBCXX__) || defined(_GLIBCXX_HAS_GTHREADS)
113 # define CRYPTOPP_CXX11_SYNCHRONIZATION 1
114 # endif
115 #endif // synchronization
116
117 // Dynamic Initialization and Destruction with Concurrency ("Magic Statics")
118 // MS at VS2015 with Vista (19.00); GCC at 4.3; LLVM Clang at 2.9; Apple Clang at 4.0; Intel 11.1; SunCC 5.13.
119 // Microsoft's implementation only works for Vista and above, so its further
120 // limited. http://connect.microsoft.com/VisualStudio/feedback/details/1789709
121 // Clang may not support this as early as we indicate. Also see https://bugs.llvm.org/show_bug.cgi?id=47012.
122 #if (__cpp_threadsafe_static_init >= 200806) || \
123 (CRYPTOPP_MSC_VERSION >= 1900) && ((WINVER >= 0x0600) || (_WIN32_WINNT >= 0x0600)) || \
124 (CRYPTOPP_LLVM_CLANG_VERSION >= 20900) || (CRYPTOPP_APPLE_CLANG_VERSION >= 40000) || \
125 (__INTEL_COMPILER >= 1110) || (CRYPTOPP_GCC_VERSION >= 40300) || (__SUNPRO_CC >= 0x5130)
126 # define CRYPTOPP_CXX11_STATIC_INIT 1
127 #endif // Dynamic Initialization compilers
128
129 // deleted functions: MS at VS2013 (18.00); GCC at 4.3; Clang at 2.9; Intel 12.1; SunCC 5.13.
130 #if (CRYPTOPP_MSC_VERSION >= 1800) || (CRYPTOPP_LLVM_CLANG_VERSION >= 20900) || \
131 (CRYPTOPP_APPLE_CLANG_VERSION >= 40000) || (__INTEL_COMPILER >= 1210) || \
132 (CRYPTOPP_GCC_VERSION >= 40300) || (__SUNPRO_CC >= 0x5130)
133 # define CRYPTOPP_CXX11_DELETED_FUNCTIONS 1
134 #endif // deleted functions
135
136 // alignof/alignas: MS at VS2015 (19.00); GCC at 4.8; Clang at 3.0; Intel 15.0; SunCC 5.13.
137 #if (CRYPTOPP_MSC_VERSION >= 1900) || __has_feature(cxx_alignas) || \
138 (__INTEL_COMPILER >= 1500) || (CRYPTOPP_GCC_VERSION >= 40800) || (__SUNPRO_CC >= 0x5130)
139 # define CRYPTOPP_CXX11_ALIGNAS 1
140 #endif // alignas
141
142 // alignof: MS at VS2015 (19.00); GCC at 4.5; Clang at 2.9; Intel 15.0; SunCC 5.13.
143 #if (CRYPTOPP_MSC_VERSION >= 1900) || __has_feature(cxx_alignof) || \
144 (__INTEL_COMPILER >= 1500) || (CRYPTOPP_GCC_VERSION >= 40500) || (__SUNPRO_CC >= 0x5130)
145 # define CRYPTOPP_CXX11_ALIGNOF 1
146 #endif // alignof
147
148 // initializer lists: MS at VS2013 (18.00); GCC at 4.4; Clang at 3.1; Intel 14.0; SunCC 5.13.
149 #if (CRYPTOPP_MSC_VERSION >= 1800) || (CRYPTOPP_LLVM_CLANG_VERSION >= 30100) || \
150 (CRYPTOPP_APPLE_CLANG_VERSION >= 40000) || (__INTEL_COMPILER >= 1400) || \
151 (CRYPTOPP_GCC_VERSION >= 40400) || (__SUNPRO_CC >= 0x5130)
152 # define CRYPTOPP_CXX11_INITIALIZER_LIST 1
153 #endif // alignas
154
155 // lambdas: MS at VS2012 (17.00); GCC at 4.9; Clang at 3.3; Intel 12.0; SunCC 5.14.
156 #if (CRYPTOPP_MSC_VERSION >= 1700) || __has_feature(cxx_lambdas) || \
157 (__INTEL_COMPILER >= 1200) || (CRYPTOPP_GCC_VERSION >= 40900) || (__SUNPRO_CC >= 0x5140)
158 # define CRYPTOPP_CXX11_LAMBDA 1
159 #endif // lambdas
160
161 // noexcept: MS at VS2015 (19.00); GCC at 4.6; Clang at 3.0; Intel 14.0; SunCC 5.13.
162 #if (CRYPTOPP_MSC_VERSION >= 1900) || __has_feature(cxx_noexcept) || \
163 (__INTEL_COMPILER >= 1400) || (CRYPTOPP_GCC_VERSION >= 40600) || (__SUNPRO_CC >= 0x5130)
164 # define CRYPTOPP_CXX11_NOEXCEPT 1
165 #endif // noexcept compilers
166
167 // variadic templates: MS at VS2013 (18.00); GCC at 4.3; Clang at 2.9; Intel 12.1; SunCC 5.13.
168 #if (__cpp_variadic_templates >= 200704) || __has_feature(cxx_variadic_templates) || \
169 (CRYPTOPP_MSC_VERSION >= 1800) || (__INTEL_COMPILER >= 1210) || \
170 (CRYPTOPP_GCC_VERSION >= 40300) || (__SUNPRO_CC >= 0x5130)
171 # define CRYPTOPP_CXX11_VARIADIC_TEMPLATES 1
172 #endif // variadic templates
173
174 // constexpr: MS at VS2015 (19.00); GCC at 4.6; Clang at 3.1; Intel 16.0; SunCC 5.13.
175 // Intel has mis-supported the feature since at least ICPC 13.00
176 #if (__cpp_constexpr >= 200704) || __has_feature(cxx_constexpr) || \
177 (CRYPTOPP_MSC_VERSION >= 1900) || (__INTEL_COMPILER >= 1600) || \
178 (CRYPTOPP_GCC_VERSION >= 40600) || (__SUNPRO_CC >= 0x5130)
179 # define CRYPTOPP_CXX11_CONSTEXPR 1
180 #endif // constexpr compilers
181
182 // strong typed enums: MS at VS2012 (17.00); GCC at 4.4; Clang at 3.3; Intel 14.0; SunCC 5.12.
183 // Mircorosft and Intel had partial support earlier, but we require full support.
184 #if (CRYPTOPP_MSC_VERSION >= 1700) || __has_feature(cxx_strong_enums) || \
185 (__INTEL_COMPILER >= 1400) || (CRYPTOPP_GCC_VERSION >= 40400) || (__SUNPRO_CC >= 0x5120)
186 # define CRYPTOPP_CXX11_STRONG_ENUM 1
187 #endif // constexpr compilers
188
189 // nullptr_t: MS at VS2010 (16.00); GCC at 4.6; Clang at 3.3; Intel 10.0; SunCC 5.13.
190 #if (CRYPTOPP_MSC_VERSION >= 1600) || __has_feature(cxx_nullptr) || \
191 (__INTEL_COMPILER >= 1000) || (CRYPTOPP_GCC_VERSION >= 40600) || \
192 (__SUNPRO_CC >= 0x5130) || defined(__IBMCPP_NULLPTR)
193 # define CRYPTOPP_CXX11_NULLPTR 1
194 #endif // nullptr_t compilers
195
196 #endif // CRYPTOPP_CXX11
197
198 // ***************** C++14 and above ********************
199
200 #if defined(CRYPTOPP_CXX14)
201
202 // Extended static_assert with one argument
203 // Microsoft cannot handle the single argument static_assert as of VS2019 (cl.exe 19.00)
204 #if (__cpp_static_assert >= 201411)
205 # define CRYPTOPP_CXX17_STATIC_ASSERT 1
206 #endif // static_assert
207
208 #endif
209
210 // ***************** C++17 and above ********************
211
212 // C++17 is available
213 #if defined(CRYPTOPP_CXX17)
214
215 // C++17 uncaught_exceptions: MS at VS2015 (19.00); GCC at 6.0; Clang at 3.5; Intel 18.0.
216 // Clang and __EXCEPTIONS see http://releases.llvm.org/3.6.0/tools/clang/docs/ReleaseNotes.html
217 // Also see https://github.com/weidai11/cryptopp/issues/980. I'm not sure what
218 // to do when the compiler defines __cpp_lib_uncaught_exceptions but the platform
219 // does not support std::uncaught_exceptions. What was Apple thinking???
220 #if defined(__clang__)
221 # if __EXCEPTIONS && __has_feature(cxx_exceptions)
222 # if __cpp_lib_uncaught_exceptions >= 201411L
223 # define CRYPTOPP_CXX17_UNCAUGHT_EXCEPTIONS 1
224 # endif
225 # endif
226 #elif (CRYPTOPP_MSC_VERSION >= 1900) || (__INTEL_COMPILER >= 1800) || \
227 (CRYPTOPP_GCC_VERSION >= 60000) || (__cpp_lib_uncaught_exceptions >= 201411L)
228 # define CRYPTOPP_CXX17_UNCAUGHT_EXCEPTIONS 1
229 #endif // uncaught_exceptions compilers
230
231 #endif // CRYPTOPP_CXX17
232
233 // ***************** C++ fixups ********************
234
235 #if defined(CRYPTOPP_CXX11_NOEXCEPT)
236 # define CRYPTOPP_THROW noexcept(false)
237 # define CRYPTOPP_NO_THROW noexcept(true)
238 #else
239 # define CRYPTOPP_THROW
240 # define CRYPTOPP_NO_THROW
241 #endif // CRYPTOPP_CXX11_NOEXCEPT
242
243 // Hack... C++11 nullptr_t type safety and analysis
244 #if defined(CRYPTOPP_CXX11_NULLPTR) && !defined(NULLPTR)
245 # define NULLPTR nullptr
246 #elif !defined(NULLPTR)
247 # define NULLPTR NULL
248 #endif // CRYPTOPP_CXX11_NULLPTR
249
250 #endif // CRYPTOPP_CONFIG_CXX_H
config_cpu.h
Library configuration file.
config_os.h
Library configuration file.
config_ver.h
Library configuration file.