打印

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

[复制链接]
4342|6
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
snakeemail|  楼主 | 2013-1-19 21:35 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
沙发
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 | 只看该作者
楼主自己已经找到答案了?
赞一个

使用特权

评论回复
5
jlass| | 2013-1-21 09:42 | 只看该作者
dirtwillfly 发表于 2013-1-20 09:56
楼主自己已经找到答案了?
赞一个

哪里都能看到你啊

使用特权

评论回复
6
inurl| | 2013-1-21 11:08 | 只看该作者
这种用法在宏定义里面经常用到 ,比如定义一个MAXNUM

使用特权

评论回复
7
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

主题

1910

帖子

8

粉丝