c - 字节中的位数 - C 标准

标签 c implementation-defined-behavior

<分区>

为什么像字节中的位数这样基本的东西一直由 C 标准实现定义?是否有这可能有用的示例?

来自 C99,3.6(可在此处获得 link)

3.6 byte

addressable unit of data storage large enough to hold any member of the basic character set of the execution environment

NOTE 1 It is possible to express the address of each individual byte of an object uniquely.

NOTE 2 A byte is composed of a contiguous sequence of bits, the number of which is implementation defined. The least significant bit is called the low-order bit; the most significant bit is called the high-order bit.

编辑:我问的是一些基本问题,为什么 C 标准在字节大小的位数方面提供了灵 active 。没有更具体地询问 sizeof(char) CHAR_BIT != 8 的好处是什么。如果问题仍然重复,请投反对票,我将关闭问题。

最佳答案

许多旧机器和当今的 DSP 具有更大的字节(例如:它们只能寻址内存的倍数,比如 16 位)。您肯定不想遗漏嵌入式世界的一个重要部分。

关于c - 字节中的位数 - C 标准,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48935886/

相关文章:

c - 如何将无符号的磁力计数据转换为度数

C var 定义,char 限制是字节还是位?

c++ - 未定义、未指定和实现定义的行为

c - 将指针指向的字符串保存到数组

c++ - g++ 没有 gcc 也能工作吗?

c - 如何在 Rust FFI 中访问 C 全局变量/常量?

c - 有符号整数溢出是否定义了未定义的行为或实现?

c++ - 为什么 boost::hana::tuple_c 的类型是实现定义的?

c++ - 有符号右移 : which compiler use logical shift