This is the mail archive of the gcc-help@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]
Other format: [Raw text]

Re: Bools and bitfields


"Paulo J. Matos" <pocmatos@gmail.com> writes:

> On Sat, Dec 12, 2009 at 2:29 AM, Ian Lance Taylor <iant@google.com> wrote:
>>
>> sizeof(bool) == 1 but the type is nevertheless just 1 bit wide. ÂThe
>> only valid values to store in a bool are 0 and 1. ÂIt doesn't make
>> sense to have a bool field that is 2 bits wide, as you can still only
>> store 0 and 1 in it.
>
> Thanks for clarifying. Indeed, I got the impression that it would be
> 1bit wide, however how can you know this without looking into the gcc
> code? I searched the documentation in the implementation dependent
> details and searched the documentation for a function that would give
> me the number of bits of a type, but couldn't find anything.
>
> Any tips on this?

Not really, sorry.  gcc doesn't document type sizes, because the
design of gcc is such that they can be target dependent, and for some
targets can even vary based on command line options.

Ian


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