1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

core: add ARRAY_SIZE macro

This commit is contained in:
Benjamin Valentin 2019-07-18 14:43:24 +02:00
parent 900fdcf783
commit fcf31724a6

View File

@ -108,6 +108,16 @@
#define UNREACHABLE() do { /* nothing */ } while (1)
#endif
/**
* @def ARRAY_SIZE(a)
* @brief Calculate the number of elements in a static array.
* @param[in] a Array to examine
* @returns The number of elements in the array a.
*/
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(a) (sizeof((a)) / sizeof((a)[0]))
#endif
/**
* @def ALIGN_OF(T)
* @brief Calculate the minimal alignment for type T.