+-
sizeof(bool)是否在C语言标准中定义?
我在标准文档中找不到答案. C语言标准是否要求sizeof(bool)始终为1(1个字节),或者是否为此大小实现定义?
最佳答案
sizeof(bool)是实现定义的,标准着重强调了这个事实.

§5.3.3/ 1,删节:

sizeof(char), sizeof(signed char) and sizeof(unsigned char) are 1; the result of sizeof applied to any other fundamental type is implementation-defined. [Note: in particular, sizeof(bool) and sizeof(wchar_t) are implementation-defined.69)]

脚注69):

sizeof(bool) is not required to be 1.

点击查看更多相关文章

转载注明原文:sizeof(bool)是否在C语言标准中定义? - 乐贴网