是的sizeof(布尔)定义的? [英] Is sizeof(bool) defined?

查看:160
本文介绍了是的sizeof(布尔)定义的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找不到标准文档中的一个答案。为的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) 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(布尔)不需要为1。

这篇关于是的sizeof(布尔)定义的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆