小编use*_*658的帖子

ARM cortex-M3 uint_fast32_t vs uint32_t

我正在为STM32Fx cortex-M3系列处理器开发一个程序.在stdint.h中定义了以下内容:

typedef unsigned int uint_fast32_t;
typedef uint32_t  uint_least32_t;
typedef unsigned long uint32_t;
Run Code Online (Sandbox Code Playgroud)

据我了解.

[u]int_fast[n]_t will give you the fastest data type of at least n bits.
[u]int_least[n]_t will give you the smallest data type of at least n bits.
[u]int[n]_t will give you the data type of exactly n bits.
Run Code Online (Sandbox Code Playgroud)

据我所知sizeof(unsigned int)<= sizeof(unsigned long)和UINT_MAX <= ULONG_MAX - 总是如此.

因此,我希望uint_fast32_t是一个大小等于或大于uint32_t大小的数据类型.

在cortex-M3 sizeof(unsigned int)== sizeof(unsigned long)== 4的情况下.因此上述定义在大小方面是"正确的".

但是为什么它们没有以与基础数据类型的名称和逻辑大小一致的方式定义,即

typedef unsigned long uint_fast32_t;
typedef unsigned int  uint_least32_t;
typedef uint_fast32_t uint32_t;
Run Code Online (Sandbox Code Playgroud)

有人可以澄清基础类型的选择吗?

鉴于'long'和'int'的大小相同,为什么不对所有三个定义使用相同的数据类型? …

c types sizeof cortex-m3 primitive-types

5
推荐指数
1
解决办法
4389
查看次数

C99的固定宽度整数类型

在这里没有得到我的问题的详细答案.我想我会从不同角度解决它.

有人能够解释用于确定C99固定宽度整数类型的基础类型的选择标准:

[u]int_fast[n]_t
[u]int_least[n]_t
[u]int[n]_t
Run Code Online (Sandbox Code Playgroud)

对于给定的处理器,如果'long'和'int'具有相同的大小(sizeof(int)== sizeof(long)),那么为什么'long'将被用于'int',反之亦然.

c int c99 fixed-width long-integer

1
推荐指数
1
解决办法
754
查看次数

标签 统计

c ×2

c99 ×1

cortex-m3 ×1

fixed-width ×1

int ×1

long-integer ×1

primitive-types ×1

sizeof ×1

types ×1