1 #include <stdio.h>
2 
3 int
main()4 main() {
5 	/* Check with more than one storage unit, and whether
6 	 * mixing with ordinary char at end works and still
7 	 * aligns properly
8 	 */
9 	struct foo {
10 		char		x; /* align me */
11 		unsigned	a:3;
12 		unsigned	b:4;
13 		unsigned	c:3;
14 		unsigned	d:17;
15 		unsigned	e:2;
16 		unsigned	f:31;
17 		unsigned	g:1;
18 	} f = { 123, 2, 6, 1, 0xff2e, 0, 0x4732363, 1 };
19 	struct foo	fa[] = {
20 		{ 33, 1, 12, 2, 0x462, 1, 0xefefef, 2 },
21 		{ 123, 2, 3, 1, 0xffe, 0, 0x32363, 1 }
22 	};
23 	int	i;
24 
25 
26 	printf("%d\n", (int)sizeof(struct foo));
27 	printf("%u, %u, %u, %u, %u, %u, %u, %u\n",
28 		f.a, f.b, f.c, f.d, f.e, f.f, f.g, f.x);
29 
30 	for (i = 0; i < 2; ++i) {
31 		printf("%u, %u, %u, %u, %u, %u, %u, %u\n",
32 			fa[i].a, fa[i].b, fa[i].c, fa[i].d, fa[i].e, fa[i].f, fa[i].g, fa[i].x);
33 	}
34 	return 0;
35 }
36 
37