From 3bd86bbea34151200cb449353a72268b6576ca2c Mon Sep 17 00:00:00 2001 From: Christoph Strehle Date: Thu, 3 Apr 2025 15:05:44 +0200 Subject: [PATCH] Fix compile break when building with the Microsoft STL Fix a compile break when building with the Microsoft STL and a compiler other then MSVC. For example when building with clang-cl --- config_ver.h | 25 ++++++++++++++++++++++--- secblock.h | 4 ++-- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/config_ver.h b/config_ver.h index 50e993707..00ef6df9c 100644 --- a/config_ver.h +++ b/config_ver.h @@ -84,9 +84,28 @@ # define CRYPTOPP_INTEL_VERSION (__INTEL_COMPILER) #endif -#if defined(_MSC_VER) && !defined(__clang__) -# undef CRYPTOPP_LLVM_CLANG_VERSION -# define CRYPTOPP_MSC_VERSION (_MSC_VER) +#if defined(_MSC_VER) +#include // needed for _MSVC_STL_VERSION +# if !defined(__clang__) +# undef CRYPTOPP_LLVM_CLANG_VERSION +# define CRYPTOPP_MSC_VERSION (_MSC_VER) +# endif +#endif + +#if defined(_MSVC_STL_VERSION) // VS2017 (14.1) and above +# define CRYPTOPP_MSSTL_VERSION _MSVC_STL_VERSION +#elif defined(_CPPLIB_VER) && _CPPLIB_VER >= 650 // VS2015 (14.0) +# define CRYPTOPP_MSSTL_VERSION 140 +#elif defined(_CPPLIB_VER) && _CPPLIB_VER >= 610 // VS2013 (12.0) +# define CRYPTOPP_MSSTL_VERSION 120 +#elif defined(_CPPLIB_VER) && _CPPLIB_VER >= 540 // VS2012 (11.0) +# define CRYPTOPP_MSSTL_VERSION 110 +#elif defined(_CPPLIB_VER) && _CPPLIB_VER >= 520 // VS2010 (10.0) +# define CRYPTOPP_MSSTL_VERSION 100 +#elif defined(_CPPLIB_VER) && _CPPLIB_VER >= 505 // VS2008SP1 (9.0) +# define CRYPTOPP_MSSTL_VERSION 91 +#elif defined(_CPPLIB_VER) && _CPPLIB_VER >= 503 // VS2008 (also 9.0) +# define CRYPTOPP_MSSTL_VERSION 90 #endif // To control include. May need a guard, like GCC 4.5 and above diff --git a/secblock.h b/secblock.h index 5ab920f9a..3fd73d13c 100644 --- a/secblock.h +++ b/secblock.h @@ -269,8 +269,8 @@ class AllocatorWithCleanup : public AllocatorBase /// store elements in the list. /// \details VS.NET STL enforces the policy of "All STL-compliant allocators /// have to provide a template class member called rebind". - template struct rebind { typedef AllocatorWithCleanup other; }; -#if (CRYPTOPP_MSC_VERSION >= 1500) + template struct rebind { typedef AllocatorWithCleanup other; }; +#if (CRYPTOPP_MSSTL_VERSION >= 90) AllocatorWithCleanup() {} template AllocatorWithCleanup(const AllocatorWithCleanup &) {} #endif