Fix unused variable declared as const under VS2022, v17.4 (GH #1185) (PR #1186)

Fix unused variable declared as const under VS2022, v17.4
This commit is contained in:
Jeffrey Walton 2023-01-16 21:53:31 -05:00 committed by GitHub
parent f0202c369e
commit 524e99f219
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 4 deletions

View File

@ -27,6 +27,16 @@
#include "config_ns.h"
#include "config_ver.h"
#include "config_misc.h"
// C5264 new for VS2022/v17.4, MSC v14.34
// https://github.com/weidai11/cryptopp/issues/1185
#if (CRYPTOPP_MSC_VERSION)
# pragma warning(push)
# if (CRYPTOPP_MSC_VERSION >= 1434)
# pragma warning(disable: 5264)
# endif
#endif
/// \brief Library byte guard
/// \details CRYPTOPP_NO_GLOBAL_BYTE indicates <tt>byte</tt> is in the Crypto++
@ -161,7 +171,7 @@ typedef word64 lword;
/// \details LWORD_MAX is the maximum value for large word types.
/// Since an <tt>lword</tt> is an unsigned type, the value is
/// <tt>0xffffffffffffffff</tt>. W64LIT will append the proper suffix.
const lword LWORD_MAX = W64LIT(0xffffffffffffffff);
CRYPTOPP_CONST_OR_CONSTEXPR lword LWORD_MAX = W64LIT(0xffffffffffffffff);
#if defined(CRYPTOPP_DOXYGEN_PROCESSING)
/// \brief Half word used for multiprecision integer arithmetic
@ -242,12 +252,17 @@ const lword LWORD_MAX = W64LIT(0xffffffffffffffff);
/// \brief Size of a platform word in bytes
/// \details The size of a platform word, in bytes
const unsigned int WORD_SIZE = sizeof(word);
CRYPTOPP_CONST_OR_CONSTEXPR unsigned int WORD_SIZE = sizeof(word);
/// \brief Size of a platform word in bits
/// \details The size of a platform word, in bits
const unsigned int WORD_BITS = WORD_SIZE * 8;
/// \sa https://github.com/weidai11/cryptopp/issues/1185
CRYPTOPP_CONST_OR_CONSTEXPR unsigned int WORD_BITS = WORD_SIZE * 8;
NAMESPACE_END
#if (CRYPTOPP_MSC_VERSION)
# pragma warning(pop)
#endif
#endif // CRYPTOPP_CONFIG_INT_H

View File

@ -145,11 +145,16 @@
#endif
// http://stackoverflow.com/a/13867690/608639
// CRYPTOPP_CONST_OR_CONSTEXPR due to https://github.com/weidai11/cryptopp/issues/1185
#if defined(CRYPTOPP_CXX11_CONSTEXPR)
# define CRYPTOPP_STATIC_CONSTEXPR static constexpr
# define CRYPTOPP_STATIC_CONST_OR_CONSTEXPR static constexpr
# define CRYPTOPP_CONST_OR_CONSTEXPR constexpr
# define CRYPTOPP_CONSTEXPR constexpr
#else
# define CRYPTOPP_STATIC_CONSTEXPR static
# define CRYPTOPP_STATIC_CONST_OR_CONSTEXPR static const
# define CRYPTOPP_CONST_OR_CONSTEXPR const
# define CRYPTOPP_CONSTEXPR
#endif // CRYPTOPP_CXX11_CONSTEXPR

View File

@ -106,9 +106,14 @@ and getting us started on the manual.
#include "stdcpp.h"
#include "trap.h"
// C5264 new for VS2022/v17.4, MSC v14.34
// https://github.com/weidai11/cryptopp/issues/1185
#if CRYPTOPP_MSC_VERSION
# pragma warning(push)
# pragma warning(disable: 4127 4189 4505 4702)
# if (CRYPTOPP_MSC_VERSION >= 1434)
# pragma warning(disable: 5264)
# endif
#endif
NAMESPACE_BEGIN(CryptoPP)
@ -127,7 +132,7 @@ enum CipherDir {
DECRYPTION};
/// \brief Represents infinite time
const unsigned long INFINITE_TIME = ULONG_MAX;
CRYPTOPP_CONST_OR_CONSTEXPR unsigned long INFINITE_TIME = ULONG_MAX;
// VC60 workaround: using enums as template parameters causes problems
/// \brief Converts an enumeration to a type suitable for use as a template parameter