summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornoloader <noloader@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2015-07-03 19:32:41 +0000
committernoloader <noloader@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2015-07-03 19:32:41 +0000
commit95472b9b3efe233a17e370566011780bbffa9d31 (patch)
treec351cd2d009908e361c38000f26d8b2586929f4b
parent483495a88d522b95339ac234dcddfa3c49f5fd8f (diff)
downloadcryptopp-95472b9b3efe233a17e370566011780bbffa9d31.tar.gz
Added COUNTOF to misc.h to count elements in an array (fails on pointers). Moved CRYPTOPP_UNUSED to misc.h
git-svn-id: svn://svn.code.sf.net/p/cryptopp/code/trunk/c5@569 57ff6487-cd31-0410-9ec3-f628ee90f5f0
-rw-r--r--config.h2
-rw-r--r--misc.h12
2 files changed, 12 insertions, 2 deletions
diff --git a/config.h b/config.h
index d853b33..be719d8 100644
--- a/config.h
+++ b/config.h
@@ -94,8 +94,6 @@
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)
typedef unsigned short word16;
diff --git a/misc.h b/misc.h
index 5b778c7..303c29c 100644
--- a/misc.h
+++ b/misc.h
@@ -66,6 +66,18 @@ struct CompileAssert
#define CRYPTOPP_ASSERT_JOIN(X, Y) CRYPTOPP_DO_ASSERT_JOIN(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 ***************
class CRYPTOPP_DLL Empty