From e8b07b162feb97d2cd1ec7ec35063e9348fc446d Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Sun, 14 Jul 2019 00:52:30 -0400 Subject: [PATCH] Avoid preprocessor error in SIZE_MAX (GH #864) --- cryptlib.cpp | 3 ++- misc.h | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/cryptlib.cpp b/cryptlib.cpp index fdcbf1bf..c4f03393 100644 --- a/cryptlib.cpp +++ b/cryptlib.cpp @@ -16,7 +16,6 @@ #ifndef CRYPTOPP_IMPORTS #include "cryptlib.h" -#include "misc.h" #include "filters.h" #include "algparam.h" #include "fips140.h" @@ -26,9 +25,11 @@ #include "secblock.h" #include "smartptr.h" #include "stdcpp.h" +#include "misc.h" NAMESPACE_BEGIN(CryptoPP) +CRYPTOPP_COMPILE_ASSERT(SIZE_MAX > 0); CRYPTOPP_COMPILE_ASSERT(sizeof(byte) == 1); CRYPTOPP_COMPILE_ASSERT(sizeof(word16) == 2); CRYPTOPP_COMPILE_ASSERT(sizeof(word32) == 4); diff --git a/misc.h b/misc.h index a90bdb75..706a1b47 100644 --- a/misc.h +++ b/misc.h @@ -117,9 +117,9 @@ // http://stackoverflow.com/questions/30472731/which-c-standard-header-defines-size-max // Avoid NOMINMAX macro on Windows. http://support.microsoft.com/en-us/kb/143208 #ifndef SIZE_MAX -# if defined(__SIZE_MAX__) && (__SIZE_MAX__ > 0) +# if defined(__SIZE_MAX__) # define SIZE_MAX __SIZE_MAX__ -# elif defined(SIZE_T_MAX) && (SIZE_T_MAX > 0) +# elif defined(SIZE_T_MAX) # define SIZE_MAX SIZE_T_MAX # elif defined(__SIZE_TYPE__) # define SIZE_MAX (~(__SIZE_TYPE__)0)