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