uint16_t和unsigned short int之间有什么区别?

我来使用一个类型为uint16_t的变量,但由于我的项目限制,我无法使用该数据类型。我可以使用unsigned short int代替uint16_t吗?
我不知道两者之间有什么区别。有人可以澄清一下吗
uint16_t是无符号的16位整数。

unsigned short int是无符号的短整数,但大小取决于实现。该标准仅表示至少为16位(即UINT_MAX的最小值为65535)。在实践中通常是16位,但是你不能保证这样做。

注意:

>如果要使用便携式无符号16位整数,请使用uint16_t。
> inttypes.h和stdint.h都在C99中引入。如果您使用C89,请定义自己的类型。
> uint16_t可能不会在某些实现中提供(参见下文),但是unsigned short int始终可用。

参考:C11(ISO / IEC 9899:201x)§7.20整数类型

For each type described herein that the implementation provides) shall declare that typedef name and define the associated macros. Conversely,for each type described herein that the implementation does not provide,shall not declare that typedef name nor shall it define the associated macros. An implementation shall provide those types described as ‘‘required’’,but need not provide any of the others (described as ‘optional’’).

相关文章

Windows2012R2备用域控搭建 前置操作 域控主域控的主dns:自...
主域控角色迁移和夺取(转载) 转载自:http://yupeizhi.blo...
Windows2012R2 NTP时间同步 Windows2012R2里没有了internet时...
Windows注册表操作基础代码 Windows下对注册表进行操作使用的...
黑客常用WinAPI函数整理之前的博客写了很多关于Windows编程的...
一个简单的Windows Socket可复用框架说起网络编程,无非是建...