我现在正在浏览“Arduino \ hardware \ tools \ avr \ avr \ include”文件夹中的avr库。在stdint.h
文件中,有一段代码:avr-gcc库中typedef int16_t int_fast16_t的用途
typedef unsigned int uint16_t __attribute__ ((__mode__ (__HI__)));
typedef signed int int32_t __attribute__ ((__mode__ (__SI__)));
typedef uint16_t uint_fast16_t;
/** \ingroup avr_stdint
fastest signed int with at least 32 bits. */
typedef int32_t int_fast32_t;
所以基本上int32_t
,int_fast32_t
和signed int __attribute__ ((__mode__ (__SI__)))
是一样的。有人可以证实吗?
如果是,为什么这样做?为什么不只是使用int32_t?
“的代码和平”通常情况下,我不对语言错误大惊小怪,但这实际上很有趣。这是“一块”,顺便说一句。没有冒犯的意思。 :-) – Downvoter
如果你问为什么'stdint.h'声明'int_(least | fast)N_t'类型以及你期望的'intN_t'类型,答案是语言标准(C99)需要最少/快速的类型,因为委员会认为它们会有用。事实证明,他们错了,但向后兼容性意味着即使几乎没有人使用它们,标题也必须继续声明它们。如果你问别的东西,我不明白你在问什么,请澄清。 – zwol
@cad。谢谢:),只是机械标记 – Qeeet