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