unkown struct typedef

I saw this in a c project (not c++):

1
2
3
4
5
6
7
typedef struct 
{
	unsigned char reach_1s	: 1;
	unsigned char reach_5hz	: 1;
	unsigned char flag_nIRQ	: 1;

}	FlagType;


I have never seen : 1 inside a typdef struct.
What does it do? initialise?
From my knowladge you use typedef to take an already initialised type and reinitialise it with other name.
E.G.:
1
2
typedef long long NAME
NAME sum; // sum will be of type NAME which is equal to long long 

Sorry for not being able to answer your question...
Last edited on
The : 1 says that each member will take up only 1 bit.
The : 1 says that each member will take up only 1 bit.


Hmm.. didn't know that that was possible.
so, the 3 chars are combined into 1?
so a variable of type FlagType will only take 1 byte of space?
and wich bit corresponds with wich bit?
I know very little about it. There is some information in http://en.wikipedia.org/wiki/Bit_field (at the bottom of Examples and bellow).
Topic archived. No new replies allowed.