1 #include <stdio.h>
2 
3 #include <stdio.h>
4 
5 // Forward declare an enumeration (only works in C, not C++)
6 typedef enum ops ops;
7 
8 struct foo {
9 	ops *op;
10 };
11 
main(int argc,char const * argv[])12 int main (int argc, char const *argv[])
13 {
14     enum bitfield {
15         None = 0,
16         A = 1 << 0,
17         B = 1 << 1,
18         C = 1 << 2,
19         AB = A | B,
20         ALL = A | B | C,
21     };
22 
23     enum non_bitfield {
24         Alpha = 3,
25         Beta = 4
26     };
27 
28     enum enum_test_days {
29         Monday = -3,
30         Tuesday,
31         Wednesday,
32         Thursday,
33         Friday,
34         Saturday,
35         Sunday,
36         kNumDays
37     };
38 
39     enum bitfield a = A, b = B, c = C, ab = AB, ac = A | C, all = ALL;
40     int nonsense = a + b + c + ab + ac + all;
41     enum non_bitfield omega = Alpha | Beta;
42 
43     enum enum_test_days day;
44     struct foo f;
45     f.op = NULL; // Breakpoint for bitfield
46     for (day = Monday - 1; day <= kNumDays + 1; day++)
47     {
48         printf("day as int is %i\n", (int)day); // Set break point at this line.
49     }
50     return 0;
51 }
52