This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

bool in bit fields?


Hi all!

Could anyone please tell me if the following piece of code
is legal according to the standard?

struct foo {
  bool bar : 1;
};

It is explicitly mentioned as legal in Stroustrup 3 and is compiled
by egcs without warning, but Kai C++ 3.3g produces the warning

  Bit-field type specified for bar is not valid. Type unsigned assumed.

I don't see the reason why using bools in bit fields should be forbidden,
but maybe this really has been changed in the final standard.

Thanks in advance,

  Martin Reinecke


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]