PER Firmware
Loading...
Searching...
No Matches
countof.h
Go to the documentation of this file.
1#ifndef COUNTOF_H
2#define COUNTOF_H
3
4// todo replace with <stdcountof.h> when gcc16 is released
5
16// internal, do not use this
17#define _COUNTOF_IS_ARRAY(x) (!__builtin_types_compatible_p(typeof(x), typeof(&(x)[0])))
18
19#define countof(array) \
20 ({ \
21 static_assert(_COUNTOF_IS_ARRAY(array), \
22 "countof() argument must be an array"); \
23 (sizeof(array) / sizeof((array)[0])); \
24 }) \
25
26#endif // COUNTOF_H