6 * alignof - ALIGNOF() macro to determine alignment of a type.
8 * Many platforms have requirements that certain types must be aligned
9 * to certain address boundaries, such as ints needing to be on 4-byte
10 * boundaries. Attempting to access variables with incorrect
11 * alignment may cause performance loss or even program failure (eg. a
14 * There are times which it's useful to be able to programatically
15 * access these requirements, such as for dynamic allocators.
20 * #include <ccan/alignof/alignof.h>
22 * int main(int argc, char *argv[])
24 * char arr[sizeof(int)];
26 * if ((unsigned long)arr % ALIGNOF(int)) {
27 * printf("arr %p CANNOT hold an int\n", arr);
30 * printf("arr %p CAN hold an int\n", arr);
35 * Licence: LGPL (2 or any later version)
37 int main(int argc, char *argv[])
42 if (strcmp(argv[1], "depends") == 0) {
43 printf("ccan/build_assert\n");