I have to do a project for school. But I got stuck right at the beginning.
I have to define type for bitfield. It isn't a problem, it would look like this:
typedef struct {
unsigned flag1 : 1;
unsigned flag2 : 1;
}BitArray;
But next task is to do set of macros for working with bitfield. One of them is:
create(field_name,size) /* defines and initializes bitfield */
The question is how can I typedef bitfield so I could change number of its members later?
Second method that came to my mind is to use bool array. But again, how can I typedef bool array? At frist I tried:
typedef bool BitArray[]; //new identifier BitArray for bool array
BitArray Array[5]; //new BitArray variable Array - this line would be in the macro mentioned above
It didn't take me a long time to realise that it won't work. However I can do:
typedef bool BitArray;
BitArray Array[5];
But it just ranames identifier for bool.
I hope my post makes sense and thank you for any advise you can give.