diff options
Diffstat (limited to 'src/helper')
-rw-r--r-- | src/helper/types.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/helper/types.h b/src/helper/types.h index 8f6283b5..96a923b8 100644 --- a/src/helper/types.h +++ b/src/helper/types.h @@ -61,6 +61,16 @@ typedef bool _Bool; /** + * Compute the number of elements of a variable length array. + * <code> + * const char *strs[] = { "a", "b", "c" }; + * unsigned num_strs = ARRAY_SIZE(strs); + * </code> + */ +#define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x))) + + +/** * Cast a member of a structure out to the containing structure. * @param ptr The pointer to the member. * @param type The type of the container struct this is embedded in. |