In C how much space does a bool (boolean) take up? Is it 1 bit, 1 byte or something else? Does it matter if the program is 32-bit or 64-bit?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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:
The standard (
6.2.5 Types, though this is also the case back toC99) states: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
6.7.2.1 Structure and union specifiersof the standard, noting in particular the "at least" section: