IAR里定义0x1Fu,最后的u表示什么意思?

[复制链接]
5035|6
 楼主| snakeemail 发表于 2013-1-19 21:35 | 显示全部楼层 |阅读模式
30000
100000L
100000UL,
后缀是什么意思,在文档里没看到有解释

 楼主| snakeemail 发表于 2013-1-19 21:38 | 显示全部楼层
本帖最后由 snakeemail 于 2013-1-19 21:42 编辑

MISRA C:1998 rules reference : constants
Constants
The rules in this section are concerned with the use of constants.
Rule 18 (advisory)
Numeric constants should be suffixed to indicate type, where an appropriate suffix is available.
How the rule is checked
The compiler will generate an error, indicating a violation of this rule, for any integer constant whose type is not the same in any standard-conforming implementation.
Example of rule violations
100000,大的就错
Examples of correct code
30000 ,小的就对?


100000L
100000UL



 楼主| snakeemail 发表于 2013-1-19 21:38 | 显示全部楼层
数值常数有:整型常数、浮点常数;
整型常数的后缀有:u或U(unsigned)、l或L(long)、u/U与l/L的组合(如:ul、lu、Lu等)。例:100u;  -123u;  0x123l;
浮点常数的后缀有:f或F(单精度浮点数)、l或L(长双精度浮点数)。(注:因浮点型常数总是有符号的,故没有u或U后缀)。例:1.23e5f;  1.23l;  -123.45f;
dirtwillfly 发表于 2013-1-20 09:56 | 显示全部楼层
楼主自己已经找到答案了?
赞一个
jlass 发表于 2013-1-21 09:42 | 显示全部楼层
dirtwillfly 发表于 2013-1-20 09:56
楼主自己已经找到答案了?
赞一个

哪里都能看到你啊
inurl 发表于 2013-1-21 11:08 | 显示全部楼层
这种用法在宏定义里面经常用到 ,比如定义一个MAXNUM
dirtwillfly 发表于 2013-1-21 11:20 | 显示全部楼层
jlass 发表于 2013-1-21 09:42
哪里都能看到你啊

呵呵,多多交流啊
您需要登录后才可以回帖 登录 | 注册

本版积分规则

个人签名:提供500W线性 交流电源。0~300VAC,45~500Hz 提供10KW,0-330V直流电源,具体见http://blog.21ic.com/user1/3639/archives/2012/88528.html

547

主题

1909

帖子

8

粉丝
快速回复 在线客服 返回列表 返回顶部