Originally Posted by
Edelweiss
Code:
typedef struct
{
uint8_t bB0:1;
uint8_t bB1:1;
uint8_t bB2:1;
uint8_t bB3:1;
uint8_t bB4:1;
uint8_t bB5:1;
uint8_t bB6:1;
uint8_t bB7:1;
}testStruct
What does the : indicates in the above struct? Does it mean 1 bit for each of them and total up to 8 bits?
In addition to Fordy's good advice...
Yes, that's what it means. As 1 bit veriables each of the elements has only 2 states... 0 or 1, usually used as on and off or true and false.
An alternate form of bitfields can look like this...
Code:
typedef struct
{
uint8_t bB0:1,
bB1:1,
bB2:1,
bB3:1,
bB4:1,
bB5:1,
bB6:1,
bB7:1;
}testStruct
But they amount to the same thing...
You should also note that not all compilers support uint8_t as a bitfield. The more common root is unsigned integer.