是的sizeof(布尔)定义的? [英] Is sizeof(bool) defined?
问题描述
我找不到标准文档中的一个答案。为的sizeof(布尔)
始终为1个字节,或者是实现定义?
I can't find an answer in the standard documentation. Is sizeof(bool)
always 1-byte, or is it implementation defined?
推荐答案
是的,这是实现定义和标准提出著名的重视使得清楚了。
Yes, it's implementation defined, and the standard puts notable emphasis on making that clear.
第5.3.3节/ 1,删节:
§5.3.3/1, abridged:
的sizeof(char)的
,的sizeof(符号字符)
和的sizeof(unsigned char型)
为1; 的sizeof的
的结果适用于任何其他基本类型是实现定义的。 [注:尤其是的sizeof(布尔)
和的sizeof(wchar_t的)
是实现定义的 69 )]
sizeof(char)
,sizeof(signed char)
andsizeof(unsigned char)
are 1; the result ofsizeof
applied to any other fundamental type is implementation-defined. [Note: in particular,sizeof(bool)
andsizeof(wchar_t)
are implementation-defined.69)]
69脚注):
的sizeof(布尔)
不需要为1。
这篇关于是的sizeof(布尔)定义的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!