【问题标题】:What does 'unsigned' mean when it's all by itself? [duplicate]当它本身是什么时,“未签名”是什么意思? [复制]
【发布时间】:2017-05-01 14:34:13
【问题描述】:

我遇到了一些 C 代码,它自己声明一个变量的“无符号”,如下所示:

unsigned crc = 0;

我认为这很奇怪,因为我希望这里有一个显式的变量类型。我很惊讶没有任何编译器警告或错误(MDK-Lite 5.12)。

那么,这是否有效,它会产生什么样的变量?

【问题讨论】:

标签: c


【解决方案1】:

来自C specification,第 6.7.2 节:

——无符号或无符号整数

意思是unsigned,当没有指定类型时,默认为unsigned int。所以写unsigned aunsigned int a是一样的。

【讨论】:

  • 6.7.2 类型说明符中定义...
  • 感谢您的具体指点。添加了引用该内容的评论。
猜你喜欢
  • 2014-10-06
  • 2014-01-08
  • 2012-04-19
  • 1970-01-01
  • 2010-09-29
  • 2020-10-27
  • 2015-07-15
  • 2018-07-17
  • 2012-08-13
相关资源
最近更新 更多