为什么在 64 位系统上 int_fast16_t 是 64 位?

Why is int_fast16_t 64 bits on a 64-bit system?

我在我的实现中查看了头文件 <stdint.h>。我看到以下内容:

typedef long int int_fast16_t;
typedef long int int_fast32_t;
typedef long int int_fast64_t;

我是64位系统,所以long int占64位。为什么所有三种数据类型都被定义为长整型?我理解 int_fast64_t 的情况,它是 64 位。但是为什么 16 位和 32 位数据类型有 64 位呢?这是某种错误吗?我创建了一个小程序来检查是否是这种情况:

sizeof(int_fast8_t) : 1
sizeof(int_fast16_t) : 8
sizeof(int_fast32_t) : 8
sizeof(int_fast64_t) : 8

是否定义了这些数据类型实现的大小?什么特征或特征将数据类型定义为 "fast"?是数据块从 RAM 加载到 CPU 的速度吗?如果 int_fast16_tint_fast32_t 都是 8 字节宽,性能上有什么好处?在64位系统上访问64位数据类型真的更快吗?

这些类型不是固定大小。它们是至少给定大小的类型,往往最快。

这些类型在 C 标准的第 7.20.1.3 节中定义:

1 Each of the following types designates an integer type that is usually fastest to operate with among all integer types that have at least the specified width.

2 The typedef name int_fastN_t designates the fastest signed integer type with a width of at least N. The typedef name uint_fastN_t designates the fastest unsigned integer type with a width of at least N.