2 ms·
With gcc you can use this to get the elements of an array. // will barf if fed a pointer #define sizeof_array(arr) \ (sizeof(arr) / sizeof((arr)[0
by Gibbon1 4y ago
With gcc you can use this to get the elements of an array.
// will barf if fed a pointer
#define sizeof_array(arr) \
(sizeof(arr) / sizeof((arr)[0]) \
+ sizeof(typeof(int[1 - 2 * \
!!__builtin_types_compatible_p(typeof(arr), \
typeof(&arr[0]))])) * 0)