bool
Alexandre Oliva
oliva@dcc.unicamp.br
Tue Nov 11 18:24:00 GMT 1997
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
More information about the Gcc
mailing list