template <bool b>
struct COMPILE_ASSERTION_FAILED_HERE;
template <>
struct COMPILE_ASSERTION_FAILED_HERE<true> {};
#define CRYPTOPP_COMPILE_ASSERT(assertion) \
CRYPTOPP_COMPILE_ASSERT_INSTANCE(assertion, __LINE__)
#define CRYPTOPP_COMPILE_ASSERT_INSTANCE(assertion, instance) \
enum { CRYPTOPP_ASSERT_JOIN(cryptopp_assert_, instance) \
= sizeof(COMPILE_ASSERTION_FAILED_HERE< (bool)( assertion ) >) }
#define CRYPTOPP_ASSERT_JOIN(X, Y) CRYPTOPP_DO_ASSERT_JOIN(X, Y)
#define CRYPTOPP_DO_ASSERT_JOIN(X, Y) X##Y
Advantages of this version over the current one:
- No extra code generated in binary files (since there are no static
variables)
- No warnings about unused variables.
- COMPILE_ASSERTION_FAILED_HERE draws more attention.
- Make compiler produce in-place error messages, i.e ones that contain
file names and line numbers causing assertion failures, instead of
complaining about some error in misc.h, which is irrelevant.
Typically, an
error message looks like this:
[file name][line num]: error: [a short phrase]
'COMPILE_ASSERTION_FAILED_HERE'
Tested compilers: GCC 4.5, MSVC 2005.
--
You received this message because you are subscribed to the "Crypto++ Users"
Google Group.
To unsubscribe, send an email to [email protected].
More information about Crypto++ and this group is available at
http://www.cryptopp.com.