stdint 的 int8_t 可以存在于没有 8 位字节的体系结构上吗? [英] Can stdint's int8_t exist on an architecture that does not have 8-bit bytes?

查看:20
本文介绍了stdint 的 int8_t 可以存在于没有 8 位字节的体系结构上吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

显然有些架构没有 8 位字节.

似乎这样的架构会排除 int8_t(在 stdint.h 中定义)类型的存在,因为根据我的理解,C 不能创建小于一个 CHAR_BIT.

It would seem that such architectures would preclude the existence of an int8_t (defined in stdint.h) type since C, from my understanding, cannot create datatypes smaller than a CHAR_BIT.

也就是说,IEEE stdint.h def似乎要求存在这种类型(以及其他类型),只允许在不支持它的架构上不存在 64 位.

That said, the IEEE stdint.h def seems to require that such a type exist (along with others), only allowing for the 64-bit to not exist on architectures that do not support it.

我错过了什么吗?

推荐答案

正如@JasonD 在下面的评论中指出的那样,链接页面在结尾处声明;

As @JasonD points out in the comments below, the linked page states at the end;

添加 int8_t 的结果是:

As a consequence of adding int8_t, the following are true:

  • 一个字节正好是 8 位.

  • A byte is exactly 8 bits.

{CHAR_BIT} 的值为 8,{SCHAR_MAX} 的值为 127,{SCHAR_MIN} 的值为 -128,{UCHAR_MAX} 的值为 255.

{CHAR_BIT} has the value 8, {SCHAR_MAX} has the value 127, {SCHAR_MIN} has the value -128, and {UCHAR_MAX} has the value 255.

换句话说,链接的 IEEE 页面不适用于字节长度不为 8 的架构.这符合需要 8 位字符的 POSIX.

In other words, the linked IEEE page does not apply to architectures with other byte lengths than 8. This is in line with POSIX which requires 8 bit char.

-- 编辑前--

<打击>解释在您链接到的页面的注释中;

整数类型的宽度"是用于在纯二进制系统中存储其值的位数;实际类型可能使用更多位(例如,28 位类型可以存储在 32 位实际存储中)

The "width" of an integer type is the number of bits used to store its value in a pure binary system; the actual type may use more bits than that (for example, a 28-bit type could be stored in 32 bits of actual storage)

这篇关于stdint 的 int8_t 可以存在于没有 8 位字节的体系结构上吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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