gpt4 book ai didi

C 没有精确指定每种数据类型的宽度

转载 作者:行者123 更新时间:2023-11-30 16:27:22 25 4
gpt4 key购买 nike

根据维基百科文章C_data_types ,有一部分提到任何数据类型如何可以是 64 位:

The actual size of the integer types varies by implementation. The standard only requires size relations between the data types and minimum sizes for each data type:

The relation requirements are that the long long is not smaller than long, which is not smaller than int, which is not smaller than short. As char's size is always the minimum supported data type, no other data types (except bit-fields) can be smaller.

The minimum size for char is 8 bits, the minimum size for short and int is 16 bits, for long it is 32 bits and long long must contain at least 64 bits.

The type int should be the integer type that the target processor is most efficiently working with. This allows great flexibility: for example, all types can be 64-bit. However, several different integer width schemes (data models) are popular. Because the data model defines how different programs communicate, a uniform data model is used within a given operating system application interface.[8]

然而,当我在大多数机器上用 C 编写代码时,我确实观察到了清晰的数据类型大小。本文只是说存在一个统一的数据模型(由大多数操作系统强制执行),该模型强制规定数据类型的大小以允许跨程序/机器轻松通信?

最佳答案

Yet, I do observe clear data type sizes when I code in C on most machines.

类型的宽度在任何一种特定的 C 实现中都是固定的。维基百科文章告诉您它们在不同的 C 实现中可能有所不同。

为此,C 实现是由特定编译器及其相关工具(链接器、标准 C 库)及其使用的设置提供的。 (某些编译器具有用于为某些类型选择不同宽度的开关。从技术上讲,此类设置的每次选择都是不同的 C 实现。)

没有统一的数据模型。有很常见的型号。操作系统无法强制执行类型宽度(部分原因是计算机实际上是通用图灵机)),但如果类型不匹配,与操作系统进行通信可能会很麻烦。

关于C 没有精确指定每种数据类型的宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52752489/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com