]> pd.if.org Git - lice/blob - tests/alignof.c
autocommit for files dated 2014-11-17 20:15:26
[lice] / tests / alignof.c
1 // alignof
2
3 #include <alignof.h>
4
5 int main(void) {
6     expecti(__alignof_is_defined, 1);
7
8     expecti(alignof(char), 1);
9     expecti(alignof(int),  4);
10     expecti(alignof(long), 8);
11
12     struct test {
13         char a;
14         int  b;
15     };
16
17     expecti(alignof(struct test), 8);
18
19     expecti(_Alignof(char), 1);
20     expecti(__alignof__(char), 1);
21     expecti(_Alignof(struct test), 8);
22     expecti(__alignof__(struct test), 8);
23
24     struct complex {
25         struct {
26             char a;
27             short b;
28             int c;
29         } d;
30         char e;
31         union {
32             int f;
33             struct {
34                 int g;
35                 int h;
36             } i;
37         } j;
38     };
39
40     expecti(alignof(struct complex), 16);
41
42     return 0;
43 }