In C how much space does a bool (boolean) take up? Is it 1 bit, 1 byte or something else?

All references to the standard herein refer to ISO C17.

The following code will show you the size of a boolean, which must be at least one given that this is the minimum addressable unit:

printf("%zu\n", sizeof(_Bool)); // Typically, but not necessarily, 1.

The standard (6.2.5 Types, though this is also the case back to C99) states:

An object declared as type _Bool is large enough to store the values 0 and 1.

As mentioned earlier, the size cannot be smaller than one(1) but it would be legal for it to be larger, as supported by footnote 124 in section Structure and union specifiers of the standard, noting in particular the “at least” section:

While the number of bits in a _Bool object is at least CHAR_BIT, the width (number of sign and value bits) of a _Bool may be just 1 bit.

Leave a Comment