R
Randy Budd
can I use enums for a bit field (as opposed to an int)?
is it valid at all?
is it undefined across platforms? (i.e. not very portable)
is it ok as long as the enums don't overrun the bitfield?
is an enum signed or unsigned?
EX
typedef enum {
TYPE_A, TYPE_B, TYPE_C,
} Type;
typedef struct {
unsigned int aType:5;
Type bType:5; /* is this O.K. ? */
unsigned int aFlag:1;
} Struct;
main()
{
Struct a;
a.aType = TYPE_B;
a.bType = TYPE_C;
....
}
is it valid at all?
is it undefined across platforms? (i.e. not very portable)
is it ok as long as the enums don't overrun the bitfield?
is an enum signed or unsigned?
EX
typedef enum {
TYPE_A, TYPE_B, TYPE_C,
} Type;
typedef struct {
unsigned int aType:5;
Type bType:5; /* is this O.K. ? */
unsigned int aFlag:1;
} Struct;
main()
{
Struct a;
a.aType = TYPE_B;
a.bType = TYPE_C;
....
}