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]

Re: bool


Per Bothner writes:

> My point is about user expectations and standardization.
> Most users will be surprised if bool takes 4 bytes.
> The natural expectation is that bool is one byte.

The natural expectation is that bool takes one bit.  bool could have
been defined as:

typedef enum {false=0, true=1} mybool;

Enums are represented as integral types large enough to hold their
whole set of values.  AFAIK, gcc won't use a single byte to represent
mybool, so why should it for a bool?

Using int as the underlying type is much faster than anything else
and, if one really wants it to be packed, s/he can use bitfields.

-- 
Alexandre Oliva
mailto:oliva@dcc.unicamp.br mailto:aoliva@acm.org
http://www.dcc.unicamp.br/~oliva
Universidade Estadual de Campinas, SP, Brasil


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