From b2d9be1b80a66b939af3921f52a760c28859df8f Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Thu, 23 Jul 2015 12:30:13 -0400 Subject: Cleared "unused variable" warning when using CRYPTOPP_STATIC_ASSERT under GCC. The "__attribute__ ((unused)" was present in GCC 2.95, so it will be available for the GCC's we support. Non-GCC's will get the non-decorated assert --- misc.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'misc.h') diff --git a/misc.h b/misc.h index 05856f34..8c709631 100644 --- a/misc.h +++ b/misc.h @@ -71,11 +71,22 @@ struct CompileAssert static char dummy[2*b-1]; }; +// __attribute__ ((unused)) will help silence the "unused variable warnings. Its available +// at least as early as GCC 2.9.3 (https://gcc.gnu.org/onlinedocs/gcc-2.95.3/gcc_4.html#SEC84) +// This also works into our -Wall -Wextra strategy for warnings. #define CRYPTOPP_COMPILE_ASSERT(assertion) CRYPTOPP_COMPILE_ASSERT_INSTANCE(assertion, __LINE__) #if defined(CRYPTOPP_EXPORTS) || defined(CRYPTOPP_IMPORTS) #define CRYPTOPP_COMPILE_ASSERT_INSTANCE(assertion, instance) #else -#define CRYPTOPP_COMPILE_ASSERT_INSTANCE(assertion, instance) static CompileAssert<(assertion)> CRYPTOPP_ASSERT_JOIN(cryptopp_assert_, instance) +# if defined(__GNUC__) +# define CRYPTOPP_COMPILE_ASSERT_INSTANCE(assertion, instance) \ + static CompileAssert<(assertion)> \ + CRYPTOPP_ASSERT_JOIN(cryptopp_assert_, instance) __attribute__ ((unused)) +# else +# define CRYPTOPP_COMPILE_ASSERT_INSTANCE(assertion, instance) \ + static CompileAssert<(assertion)> \ + CRYPTOPP_ASSERT_JOIN(cryptopp_assert_, instance) +# endif // __GNUC__ #endif #define CRYPTOPP_ASSERT_JOIN(X, Y) CRYPTOPP_DO_ASSERT_JOIN(X, Y) #define CRYPTOPP_DO_ASSERT_JOIN(X, Y) X##Y -- cgit v1.2.1