Guarded COUNTOF macro. Thanks to Graham Bull for the suggestion
parent
aa8bb8c5cd
commit
8386b3f139
2
misc.h
2
misc.h
|
|
@ -72,11 +72,13 @@ struct CompileAssert
|
||||||
|
|
||||||
// ************** counting elements in an array ***************
|
// ************** counting elements in an array ***************
|
||||||
// VS2005 added _countof macro, fails on pointers
|
// VS2005 added _countof macro, fails on pointers
|
||||||
|
#ifndef COUNTOF
|
||||||
# if defined(_MSC_VER) && (_MSC_VER >= 1400)
|
# if defined(_MSC_VER) && (_MSC_VER >= 1400)
|
||||||
# define COUNTOF(x) _countof(x)
|
# define COUNTOF(x) _countof(x)
|
||||||
# else
|
# else
|
||||||
# define COUNTOF(x) (sizeof(x)/sizeof(x[0]))
|
# define COUNTOF(x) (sizeof(x)/sizeof(x[0]))
|
||||||
# endif
|
# endif
|
||||||
|
#endif // COUNTOF
|
||||||
|
|
||||||
// ************** misc classes ***************
|
// ************** misc classes ***************
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue