I'd like to get the following checked in to add some type safety to places where sizeof(x)/sizeof(x[0]) is used.
On Microsoft platforms, the type checks will be in-force. Other platforms will enjoy the diagnostics from the Windows platform. I am going to resist expanding it to other platforms (similar to http://stackoverflow.com/q/9679097). Its hard to test some of the older platforms, so I'm not sure if the cleverness is worth potentially breaking a compile. Any comments or objections? ********** $ git diff config.h diff --git a/config.h b/config.h index d853b33..1667598 100644 --- a/config.h +++ b/config.h @@ -96,6 +96,12 @@ typedef unsigned char byte; // put in global namespa #define CRYPTOPP_UNUSED(x) ((void)x) // cast to void. Portable way to +#if defined(_MSC_VER) && (_MSC_VER >= 1400) // VS2005 added _countof +# defined COUNTOF(x) _countof(x) +#else +# define COUNTOF(x) (sizeof(x)/sizeof(x[0])) +#endif + NAMESPACE_BEGIN(CryptoPP) -- -- 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. --- You received this message because you are subscribed to the Google Groups "Crypto++ Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
