加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

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

发布时间:2020-12-13 20:57:13 所属栏目:Windows 来源:网络整理
导读:我来使用一个类型为uint16_t的变量,但由于我的项目限制,我无法使用该数据类型。我可以使用unsigned short int代替uint16_t吗? 我不知道两者之间有什么区别。有人可以澄清一下吗 uint16_t是无符号的16位整数。 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’’).

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读