Q
Quentin Pope
Hello,
Does the C standard say anything about using enum in a bit field? Like
enum {
apple,
orange
} fruit;
struct {
enum fruit f:16;
};
Gcc does not complain about this when -ansi or -pedantic is turned
OFF. XLC (claims to be an ANSI C compiler) on the IBM RS/6000 issued
a warning and treat it like an unsigned integer. K&R 2nd Ed says
nothing explicitly about this but it says that bit fields are
`implementation dependant' and `always unsigned'.
I think this is very useful and in our project we encourage people to use
enum instead of #define to create constants. Although not used in a lot
of places, the bit field somewhat defeats this purpose. Is there a
rationale why this is so? Is there any way to shut up the compiler?
I've checked the FAQ. No answers from there.
Thanks
QP
Does the C standard say anything about using enum in a bit field? Like
enum {
apple,
orange
} fruit;
struct {
enum fruit f:16;
};
Gcc does not complain about this when -ansi or -pedantic is turned
OFF. XLC (claims to be an ANSI C compiler) on the IBM RS/6000 issued
a warning and treat it like an unsigned integer. K&R 2nd Ed says
nothing explicitly about this but it says that bit fields are
`implementation dependant' and `always unsigned'.
I think this is very useful and in our project we encourage people to use
enum instead of #define to create constants. Although not used in a lot
of places, the bit field somewhat defeats this purpose. Is there a
rationale why this is so? Is there any way to shut up the compiler?
I've checked the FAQ. No answers from there.
Thanks
QP