I have to make a couple of changes to a C program. I haven't used C in decades.
I have C++ code I wish I could make work with a C compiler by making some simple changes.
Can this code, and others like it, be made to compile as C?
One problem, I suppose, is structs in C++ are automatically types. In C, structs have to be kicked in the head to make them types. I guess the same is true of unions.
In the following code, Control_b, (capital C) is a type. It's a union of an 8 bit int called byte, and a bit field called bits. At the terminating }; that ends the union, the C compiler sez, declaration does not declare anything.
union Control_b { struct { Register attach : 1; // ATTACH Register global_NACK : 1; // GNACK Register remote_wake_up : 1; // RWAKEUP Register reserved_3 : 1; // Reserved Register pullup_held_during_reset : 1; // PULLRST Register reserved_5_7 : 3; // Reserved } bits; Register byte; }; // <---- C compiler sez, declaration does not declare anything. volatile Control_b control_b;