Added COUNTOF to misc.h to count elements in an array (fails on pointers). Moved CRYPTOPP_UNUSED to misc.h

reviewable/pr7/r1
Jeffrey Walton 2015-07-03 15:40:44 -04:00
parent 63dd0f5f54
commit f2379159f8
2 changed files with 12 additions and 2 deletions

View File

@ -94,8 +94,6 @@
typedef unsigned char byte; // put in global namespace to avoid ambiguity with other byte typedefs typedef unsigned char byte; // put in global namespace to avoid ambiguity with other byte typedefs
#define CRYPTOPP_UNUSED(x) ((void)x) // cast to void. Portable way to suppress unused variable
NAMESPACE_BEGIN(CryptoPP) NAMESPACE_BEGIN(CryptoPP)
typedef unsigned short word16; typedef unsigned short word16;

12
misc.h
View File

@ -66,6 +66,18 @@ struct CompileAssert
#define CRYPTOPP_ASSERT_JOIN(X, Y) CRYPTOPP_DO_ASSERT_JOIN(X, Y) #define CRYPTOPP_ASSERT_JOIN(X, Y) CRYPTOPP_DO_ASSERT_JOIN(X, Y)
#define CRYPTOPP_DO_ASSERT_JOIN(X, Y) X##Y #define CRYPTOPP_DO_ASSERT_JOIN(X, Y) X##Y
// ************** unused variable suppression ***************
// Cast to void. Portable way to suppress warning
#define CRYPTOPP_UNUSED(x) ((void)x)
// ************** counting elements in an array ***************
// VS2005 added _countof macro, fails on pointers
#if defined(_MSC_VER) && (_MSC_VER >= 1400)
# define COUNTOF(x) _countof(x)
#else
# define COUNTOF(x) (sizeof(x)/sizeof(x[0]))
#endif
// ************** misc classes *************** // ************** misc classes ***************
class CRYPTOPP_DLL Empty class CRYPTOPP_DLL Empty