winbind: Introduce "struct child_handler_state"
[Samba/gebeck_regimport.git] / lib / ccan / array_size / array_size.h
blob0876945c5e52a7c19e034fb8fdd1ff5e75d1305f
1 #ifndef CCAN_ARRAY_SIZE_H
2 #define CCAN_ARRAY_SIZE_H
3 #include "config.h"
4 #include <ccan/build_assert/build_assert.h>
6 /**
7 * ARRAY_SIZE - get the number of elements in a visible array
8 * @arr: the array whose size you want.
10 * This does not work on pointers, or arrays declared as [], or
11 * function parameters. With correct compiler support, such usage
12 * will cause a build error (see build_assert).
14 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + _array_size_chk(arr))
16 #if HAVE_BUILTIN_TYPES_COMPATIBLE_P && HAVE_TYPEOF
17 /* Two gcc extensions.
18 * &a[0] degrades to a pointer: a different type from an array */
19 #define _array_size_chk(arr) \
20 BUILD_ASSERT_OR_ZERO(!__builtin_types_compatible_p(typeof(arr), \
21 typeof(&(arr)[0])))
22 #else
23 #define _array_size_chk(arr) 0
24 #endif
25 #endif /* CCAN_ALIGNOF_H */