[cfe-dev] bool bitfields

Douglas Gregor dgregor at apple.com
Tue Sep 14 09:26:29 PDT 2010


On Sep 14, 2010, at 9:09 AM, Ted Kremenek wrote:

> For "boolean" bitfields, we sometimes use "unsigned" and sometimes use "bool", e.g.:
> 
> $ grep ': 1;' *
> ...
> Type.h:  bool SubClassData : 1;
> ...
> Type.h:  unsigned NoReturn : 1;
> ...
> 
> I vaguely recall that we switched to using "unsigned" a while back for bitfields that were enums (I believe that enums are being treated as "signed" by Visual C++).  Since these are bools, not enum, what should we be doing here?  It would be nice to be consistent.

"bool" is the natural type for these flags, so I suggest we stick with it.

	- Doug





More information about the cfe-dev mailing list