Being new to bitfields, I need some advice as to whats going on with various examples i've seen online. I'm wanting to use bitfields instead of bitmasks for readability, and maintenance ease later on for new ppl.
This is a common means of declaring a bitfield:
typedef enum
{
unsigned int x: 1;
unsigned int y: 1;
}statusBits1;
So far so good, then i've seen:
typedef enum
{
unsigned int x = 1 << 0,
unsigned int y = 1 << 1
}statusBits2;
In my learning, i believe this sets the default values for any statusBits2 datatypes. Does this also set the size of x and y to 1 bit fields like in statusBits1? A combination of both is what i'm looking for.
thanks in advance.
EDIT: Thank you for the answers! You forced me to reread what i've been studying. I was intermingling info from various posts regarding bitfields and bitmasks!
Namely these:
Declaring and checking/comparing (bitmask-)enums in Objective-C
http://forum.codecall.net/topic/56591-bit-fields-flags-tutorial-with-example/
I'm coming back to C from a few years working in C#/C++, and relearning bit fiddling.