From 8386b3f139110077d0f92ccd1c54564019deb60b Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Sun, 5 Jul 2015 17:53:42 -0400 Subject: [PATCH] Guarded COUNTOF macro. Thanks to Graham Bull for the suggestion --- misc.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/misc.h b/misc.h index 303c29c6..b6a1b868 100644 --- a/misc.h +++ b/misc.h @@ -72,11 +72,13 @@ struct CompileAssert // ************** 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 +#ifndef COUNTOF +# if defined(_MSC_VER) && (_MSC_VER >= 1400) +# define COUNTOF(x) _countof(x) +# else +# define COUNTOF(x) (sizeof(x)/sizeof(x[0])) +# endif +#endif // COUNTOF // ************** misc classes ***************