1 | struct Empty {}; |
---|---|
2 | struct EmptyMember { |
3 | char i[0]; |
4 | }; |
5 | struct SingleMember { |
6 | int i; |
7 | }; |
8 | |
9 | struct PaddingMember { |
10 | int i; |
11 | char c; |
12 | }; |
13 | |
14 | const unsigned sizeof_empty = sizeof(struct Empty); |
15 | const unsigned sizeof_empty_member = sizeof(struct EmptyMember); |
16 | const unsigned sizeof_single = sizeof(struct SingleMember); |
17 | const unsigned sizeof_padding = sizeof(struct PaddingMember); |
18 | |
19 | int main() { |
20 | struct Empty empty; |
21 | struct EmptyMember empty_member; |
22 | struct SingleMember single; |
23 | struct PaddingMember padding; |
24 | // Make sure globals are used. |
25 | return sizeof_empty + sizeof_empty_member + sizeof_single + sizeof_padding; |
26 | } |
27 |