Skip to content

Instantly share code, notes, and snippets.

@baiyanhuang
Created June 17, 2012 03:13
Show Gist options
  • Save baiyanhuang/2943277 to your computer and use it in GitHub Desktop.
Save baiyanhuang/2943277 to your computer and use it in GitHub Desktop.
A macro to get array size
#ifndef _LZ_UTILITY_COMMON_H
#define _LZ_UTILITY_COMMON_H
// Array size
template <typename T, size_t N>
char ( &_ArraySizeHelper( T (&array)[N] ) ) [N];
#define ARRAY_SIZE(array) ( sizeof( _ArraySizeHelper(array) ) )
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment