This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: bool
- To: Per Bothner <bothner at cygnus dot com>
- Subject: Re: bool
- From: Alexandre Oliva <oliva at dcc dot unicamp dot br>
- Date: 12 Nov 1997 00:19:18 -0200
- Cc: egcs at cygnus dot com
- References: <199711112028.MAA08953@cygnus.com>
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