xref: /original-bsd/old/dbx/tests/cc/bitfields.c (revision e1db577d)
1 typedef unsigned int uint;
2 
3 struct dot {
4     uint  cost		 :24;
5     uint  type	         : 3;
6     uint  dirToCenter	 : 3;
7     uint  pad		 : 1;
8     uint  pin		 : 1;
9     uint  traceback	 : 3;
10     uint  traceforward   : 3;
11     uint  expanded	 : 1;
12     uint  underDir	 : 3;
13     uint  underOffset	 : 4;
14     uint  start		 : 1;
15     uint  target	 : 1;
16     uint  owner		 : 6;
17     uint  segment	 : 7;
18     uint  intrinsicCost  : 3;
19 };
20 
21 main()
22 {
23     struct dot junk;
24 
25     junk.owner = 63;
26     junk.segment = 1;
27     junk.intrinsicCost = 1;
28 
29     printf("owner = %d, segment = %d, intrinsicCost = %d\n",
30 	junk.owner, junk.segment, junk.intrinsicCost);
31     printf("done\n");
32     oldmain();
33 }
34 
35 oldmain()
36 {
37     struct {
38 	int first;
39 	int second;
40 	int a : 8;
41 	int b : 8;
42 	int c;
43     } x;
44 
45     x.first = 0;
46     x.second = 0;
47     x.a = 2;
48     x.b = 10;
49     x.c = 1;
50 }
51