Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:54:55

0001 // config_cxx.h - written and placed in public domain by Jeffrey Walton

0002 //                the bits that make up this source file are from the

0003 //                library's monolithic config.h.

0004 
0005 /// \file config_cxx.h

0006 /// \brief Library configuration file

0007 /// \details <tt>config_cxx.h</tt> provides defines for C++ language and

0008 ///  runtime library

0009 ///  features.

0010 /// \details <tt>config.h</tt> was split into components in May 2019 to better

0011 ///  integrate with Autoconf and its feature tests. The splitting occurred so

0012 ///  users could continue to include <tt>config.h</tt> while allowing Autoconf

0013 ///  to write new <tt>config_asm.h</tt> and new <tt>config_cxx.h</tt> using

0014 ///  its feature tests.

0015 /// \note You should include <tt>config.h</tt> rather than <tt>config_cxx.h</tt>

0016 ///  directly.

0017 /// \sa <A HREF="https://github.com/weidai11/cryptopp/issues/835">Issue 835,

0018 ///  Make config.h more autoconf friendly</A>,

0019 ///  <A HREF="https://www.cryptopp.com/wiki/Configure.sh">Configure.sh script</A>

0020 ///  on the Crypto++ wiki

0021 /// \since Crypto++ 8.3

0022 
0023 // Visual Studio began at VS2010, http://msdn.microsoft.com/en-us/library/hh567368%28v=vs.110%29.aspx

0024 //   and https://docs.microsoft.com/en-us/cpp/visual-cpp-language-conformance

0025 // Intel, http://software.intel.com/en-us/articles/c0x-features-supported-by-intel-c-compiler

0026 // GCC, http://gcc.gnu.org/projects/cxx0x.html

0027 // Clang, http://clang.llvm.org/cxx_status.html

0028 
0029 #ifndef CRYPTOPP_CONFIG_CXX_H
0030 #define CRYPTOPP_CONFIG_CXX_H
0031 
0032 #include "config_os.h"
0033 #include "config_cpu.h"
0034 #include "config_ver.h"
0035 
0036 // https://github.com/weidai11/cryptopp/issues/960

0037 #include <string>
0038 #include <exception>
0039 
0040 // You may need to force include a C++ header on Android when using STLPort

0041 // to ensure _STLPORT_VERSION is defined

0042 #if (defined(CRYPTOPP_MSC_VERSION) && CRYPTOPP_MSC_VERSION <= 1300) || \
0043     defined(__MWERKS__) || \
0044     (defined(_STLPORT_VERSION) && ((_STLPORT_VERSION < 0x450) || defined(_STLP_NO_UNCAUGHT_EXCEPT_SUPPORT)) || \
0045     (__cplusplus >= 202002L))
0046 #define CRYPTOPP_DISABLE_UNCAUGHT_EXCEPTION
0047 #endif
0048 
0049 // Ancient Crypto++ define, dating back to C++98.

0050 #ifndef CRYPTOPP_DISABLE_UNCAUGHT_EXCEPTION
0051 # define CRYPTOPP_UNCAUGHT_EXCEPTION_AVAILABLE 1
0052 # define CRYPTOPP_CXX98_UNCAUGHT_EXCEPTION 1
0053 #endif
0054 
0055 // Compatibility with non-clang compilers.

0056 #ifndef __has_feature
0057 # define __has_feature(x) 0
0058 #endif
0059 
0060 // C++11 macro version, https://stackoverflow.com/q/7223991/608639

0061 #if ((CRYPTOPP_MSC_VERSION >= 1600) || (__cplusplus >= 201103L)) && !defined(_STLPORT_VERSION)
0062 #  define CRYPTOPP_CXX11 1
0063 #endif
0064 
0065 // Hack ahead. Apple's standard library does not have C++'s unique_ptr in C++11.

0066 // We can't test for unique_ptr directly because some of the non-Apple Clangs

0067 // on OS X fail the same way. However, modern standard libraries have

0068 // <forward_list>, so we test for it instead. Thanks to Jonathan Wakely for

0069 // devising the clever test for modern/ancient versions. TODO: test under

0070 // Xcode 3, where g++ is really g++.

0071 #if defined(__APPLE__) && defined(__clang__)
0072 #  if !(defined(__has_include) && __has_include(<forward_list>))
0073 #    undef CRYPTOPP_CXX11
0074 #  endif
0075 #endif
0076 
0077 // C++14 macro version, https://stackoverflow.com/q/26089319/608639

0078 #if defined(CRYPTOPP_CXX11) && !defined(CRYPTOPP_NO_CXX14)
0079 #  if ((CRYPTOPP_MSC_VERSION >= 1900) || (__cplusplus >= 201402L)) && !defined(_STLPORT_VERSION)
0080 #    define CRYPTOPP_CXX14 1
0081 #  endif
0082 #endif
0083 
0084 // C++17 macro version, https://stackoverflow.com/q/38456127/608639

0085 #if defined(CRYPTOPP_CXX14) && !defined(CRYPTOPP_NO_CXX17)
0086 #  if ((CRYPTOPP_MSC_VERSION >= 1900) || (__cplusplus >= 201703L)) && !defined(_STLPORT_VERSION)
0087 #    define CRYPTOPP_CXX17 1
0088 #  endif
0089 #endif
0090 
0091 // ***************** C++11 and above ********************

0092 
0093 #if defined(CRYPTOPP_CXX11)
0094 
0095 // atomics: MS at VS2012 (17.00); GCC at 4.4; Clang at 3.1/3.2; Intel 13.0; SunCC 5.14.

0096 #if (CRYPTOPP_MSC_VERSION >= 1700) || __has_feature(cxx_atomic) || \
0097     (__INTEL_COMPILER >= 1300) || (CRYPTOPP_GCC_VERSION >= 40400) || (__SUNPRO_CC >= 0x5140)
0098 # define CRYPTOPP_CXX11_ATOMIC 1
0099 #endif // atomics

0100 
0101 // synchronization: MS at VS2012 (17.00); GCC at 4.4; Clang at 3.3; Xcode 5.0; Intel 12.0; SunCC 5.13.

0102 // TODO: verify Clang and Intel versions; find __has_feature(x) extension for Clang

0103 #if (CRYPTOPP_MSC_VERSION >= 1700) || (CRYPTOPP_LLVM_CLANG_VERSION >= 30300) || \
0104     (CRYPTOPP_APPLE_CLANG_VERSION >= 50000) || (__INTEL_COMPILER >= 1200) || \
0105     (CRYPTOPP_GCC_VERSION >= 40400) || (__SUNPRO_CC >= 0x5130)
0106 // Hack ahead. New GCC compilers like GCC 6 on AIX 7.0 or earlier as well as original MinGW

0107 // don't have the synchronization gear. However, Wakely's test used for Apple does not work

0108 // on the GCC/AIX combination. Another twist is we need other stuff from C++11,

0109 // like no-except destructors. Dumping preprocessors shows the following may

0110 // apply: http://stackoverflow.com/q/14191566/608639.

0111 # include <cstddef>
0112 # if !defined(__GLIBCXX__) || defined(_GLIBCXX_HAS_GTHREADS)
0113 #  define CRYPTOPP_CXX11_SYNCHRONIZATION 1
0114 # endif
0115 #endif // synchronization

0116 
0117 // Dynamic Initialization and Destruction with Concurrency ("Magic Statics")

0118 // 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.

0119 // Microsoft's implementation only works for Vista and above, so its further

0120 // limited. http://connect.microsoft.com/VisualStudio/feedback/details/1789709

0121 // Clang may not support this as early as we indicate. Also see https://bugs.llvm.org/show_bug.cgi?id=47012.

0122 #if (__cpp_threadsafe_static_init >= 200806) || \
0123     (CRYPTOPP_MSC_VERSION >= 1900) && ((WINVER >= 0x0600) || (_WIN32_WINNT >= 0x0600)) || \
0124     (CRYPTOPP_LLVM_CLANG_VERSION >= 20900) || (CRYPTOPP_APPLE_CLANG_VERSION >= 40000)  || \
0125     (__INTEL_COMPILER >= 1110) || (CRYPTOPP_GCC_VERSION >= 40300) || (__SUNPRO_CC >= 0x5130)
0126 # define CRYPTOPP_CXX11_STATIC_INIT 1
0127 #endif // Dynamic Initialization compilers

0128 
0129 // deleted functions: MS at VS2013 (18.00); GCC at 4.3; Clang at 2.9; Intel 12.1; SunCC 5.13.

0130 #if (CRYPTOPP_MSC_VERSION >= 1800) || (CRYPTOPP_LLVM_CLANG_VERSION >= 20900) || \
0131     (CRYPTOPP_APPLE_CLANG_VERSION >= 40000) || (__INTEL_COMPILER >= 1210) || \
0132     (CRYPTOPP_GCC_VERSION >= 40300) || (__SUNPRO_CC >= 0x5130)
0133 # define CRYPTOPP_CXX11_DELETED_FUNCTIONS 1
0134 #endif // deleted functions

0135 
0136 // alignof/alignas: MS at VS2015 (19.00); GCC at 4.8; Clang at 3.0; Intel 15.0; SunCC 5.13.

0137 #if (CRYPTOPP_MSC_VERSION >= 1900) || __has_feature(cxx_alignas) || \
0138     (__INTEL_COMPILER >= 1500) || (CRYPTOPP_GCC_VERSION >= 40800) || (__SUNPRO_CC >= 0x5130)
0139 #  define CRYPTOPP_CXX11_ALIGNAS 1
0140 #endif // alignas

0141 
0142 // alignof: MS at VS2015 (19.00); GCC at 4.5; Clang at 2.9; Intel 15.0; SunCC 5.13.

0143 #if (CRYPTOPP_MSC_VERSION >= 1900) || __has_feature(cxx_alignof) || \
0144     (__INTEL_COMPILER >= 1500) || (CRYPTOPP_GCC_VERSION >= 40500) || (__SUNPRO_CC >= 0x5130)
0145 #  define CRYPTOPP_CXX11_ALIGNOF 1
0146 #endif // alignof

0147 
0148 // initializer lists: MS at VS2013 (18.00); GCC at 4.4; Clang at 3.1; Intel 14.0; SunCC 5.13.

0149 #if (CRYPTOPP_MSC_VERSION >= 1800) || (CRYPTOPP_LLVM_CLANG_VERSION >= 30100) || \
0150     (CRYPTOPP_APPLE_CLANG_VERSION >= 40000) || (__INTEL_COMPILER >= 1400) || \
0151     (CRYPTOPP_GCC_VERSION >= 40400) || (__SUNPRO_CC >= 0x5130)
0152 #  define CRYPTOPP_CXX11_INITIALIZER_LIST 1
0153 #endif // alignas

0154 
0155 // lambdas: MS at VS2012 (17.00); GCC at 4.9; Clang at 3.3; Intel 12.0; SunCC 5.14.

0156 #if (CRYPTOPP_MSC_VERSION >= 1700) || __has_feature(cxx_lambdas) || \
0157     (__INTEL_COMPILER >= 1200) || (CRYPTOPP_GCC_VERSION >= 40900) || (__SUNPRO_CC >= 0x5140)
0158 #  define CRYPTOPP_CXX11_LAMBDA 1
0159 #endif // lambdas

0160 
0161 // noexcept: MS at VS2015 (19.00); GCC at 4.6; Clang at 3.0; Intel 14.0; SunCC 5.13.

0162 #if (CRYPTOPP_MSC_VERSION >= 1900) || __has_feature(cxx_noexcept) || \
0163     (__INTEL_COMPILER >= 1400) || (CRYPTOPP_GCC_VERSION >= 40600) || (__SUNPRO_CC >= 0x5130)
0164 # define CRYPTOPP_CXX11_NOEXCEPT 1
0165 #endif // noexcept compilers

0166 
0167 // variadic templates: MS at VS2013 (18.00); GCC at 4.3; Clang at 2.9; Intel 12.1; SunCC 5.13.

0168 #if (__cpp_variadic_templates >= 200704) || __has_feature(cxx_variadic_templates) || \
0169     (CRYPTOPP_MSC_VERSION >= 1800) || (__INTEL_COMPILER >= 1210) || \
0170     (CRYPTOPP_GCC_VERSION >= 40300) || (__SUNPRO_CC >= 0x5130)
0171 # define CRYPTOPP_CXX11_VARIADIC_TEMPLATES 1
0172 #endif // variadic templates

0173 
0174 // constexpr: MS at VS2015 (19.00); GCC at 4.6; Clang at 3.1; Intel 16.0; SunCC 5.13.

0175 // Intel has mis-supported the feature since at least ICPC 13.00

0176 #if (__cpp_constexpr >= 200704) || __has_feature(cxx_constexpr) || \
0177     (CRYPTOPP_MSC_VERSION >= 1900) || (__INTEL_COMPILER >= 1600) || \
0178     (CRYPTOPP_GCC_VERSION >= 40600) || (__SUNPRO_CC >= 0x5130)
0179 # define CRYPTOPP_CXX11_CONSTEXPR 1
0180 #endif // constexpr compilers

0181 
0182 // strong typed enums: MS at VS2012 (17.00); GCC at 4.4; Clang at 3.3; Intel 14.0; SunCC 5.12.

0183 // Mircorosft and Intel had partial support earlier, but we require full support.

0184 #if (CRYPTOPP_MSC_VERSION >= 1700) || __has_feature(cxx_strong_enums) || \
0185     (__INTEL_COMPILER >= 1400) || (CRYPTOPP_GCC_VERSION >= 40400) || (__SUNPRO_CC >= 0x5120)
0186 # define CRYPTOPP_CXX11_STRONG_ENUM 1
0187 #endif // constexpr compilers

0188 
0189 // nullptr_t: MS at VS2010 (16.00); GCC at 4.6; Clang at 3.3; Intel 10.0; SunCC 5.13.

0190 #if (CRYPTOPP_MSC_VERSION >= 1600) || __has_feature(cxx_nullptr) || \
0191     (__INTEL_COMPILER >= 1000) || (CRYPTOPP_GCC_VERSION >= 40600) || \
0192     (__SUNPRO_CC >= 0x5130) || defined(__IBMCPP_NULLPTR)
0193 # define CRYPTOPP_CXX11_NULLPTR 1
0194 #endif // nullptr_t compilers

0195 
0196 #endif // CRYPTOPP_CXX11

0197 
0198 // ***************** C++14 and above ********************

0199 
0200 #if defined(CRYPTOPP_CXX14)
0201 
0202 // Extended static_assert with one argument

0203 // Microsoft cannot handle the single argument static_assert as of VS2019 (cl.exe 19.00)

0204 #if (__cpp_static_assert >= 201411)
0205 # define CRYPTOPP_CXX17_STATIC_ASSERT 1
0206 #endif // static_assert

0207 
0208 #endif
0209 
0210 // ***************** C++17 and above ********************

0211 
0212 // C++17 is available

0213 #if defined(CRYPTOPP_CXX17)
0214 
0215 // C++17 uncaught_exceptions: MS at VS2015 (19.00); GCC at 6.0; Clang at 3.5; Intel 18.0.

0216 // Clang and __EXCEPTIONS see http://releases.llvm.org/3.6.0/tools/clang/docs/ReleaseNotes.html

0217 // Also see https://github.com/weidai11/cryptopp/issues/980. I'm not sure what

0218 // to do when the compiler defines __cpp_lib_uncaught_exceptions but the platform

0219 // does not support std::uncaught_exceptions. What was Apple thinking???

0220 #if defined(__clang__)
0221 # if __EXCEPTIONS && __has_feature(cxx_exceptions)
0222 #  if __cpp_lib_uncaught_exceptions >= 201411L
0223 #   define CRYPTOPP_CXX17_UNCAUGHT_EXCEPTIONS 1
0224 #  endif
0225 # endif
0226 #elif (CRYPTOPP_MSC_VERSION >= 1900) || (__INTEL_COMPILER >= 1800) || \
0227       (CRYPTOPP_GCC_VERSION >= 60000) || (__cpp_lib_uncaught_exceptions >= 201411L)
0228 # define CRYPTOPP_CXX17_UNCAUGHT_EXCEPTIONS 1
0229 #endif // uncaught_exceptions compilers

0230 
0231 #endif  // CRYPTOPP_CXX17

0232 
0233 // ***************** C++ fixups ********************

0234 
0235 #if defined(CRYPTOPP_CXX11_NOEXCEPT)
0236 #  define CRYPTOPP_THROW noexcept(false)
0237 #  define CRYPTOPP_NO_THROW noexcept(true)
0238 #else
0239 #  define CRYPTOPP_THROW
0240 #  define CRYPTOPP_NO_THROW
0241 #endif // CRYPTOPP_CXX11_NOEXCEPT

0242 
0243 // Hack... C++11 nullptr_t type safety and analysis

0244 #if defined(CRYPTOPP_CXX11_NULLPTR) && !defined(NULLPTR)
0245 # define NULLPTR nullptr
0246 #elif !defined(NULLPTR)
0247 # define NULLPTR NULL
0248 #endif // CRYPTOPP_CXX11_NULLPTR

0249 
0250 #endif  // CRYPTOPP_CONFIG_CXX_H