完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
电子发烧友论坛|
嗨,那里。当我编译这个项目时,我遇到了这个警告。这里是我的代码:警告显示:困难。C:53:警告:(751)常数表达式中的算术溢出,然后我看了XC8编译器用户指南,并说:这个警告也可以由中间值溢出触发。例如:无符号int i;/*假定INT是16位宽*/i=240×137;/*这应该可以,对不对?*用计算器快速检查显示240×137是32880,它可以很容易地存储在无符号int中,但是会产生警告。为什么?因为240和137都是int值。因此,乘法的结果也必须是符号int值,但已签名的int不能保存值32880。(两个操作数都是常数值,所以代码生成器可以在编译时评估这个表达式,但它必须遵从所有ANSI C规则。)下面的代码强制执行用未签名的结果:I= 240U* 137;/*强制至少一个操作数为无符号*/所以我把我的代码改成:但是,它仍然不能工作。然后我再次查看XC8编译器用户指南,它说(附件1)问题:后缀U或U支持无符号短长?或者我需要改变数据类型从无符号短长到无符号长,后缀U还是U?
以上来自于百度翻译 以下为原文 Hi, there. I run into this warning when I compiled the project. Here is my code: #define MINUTES(x) x*60*1000 //macro unsigned short long UV_CountDown = MINUTES(120); unsigned short long CVCountDown = MINUTES(130); unsigned short long WHOLE_CountDown = MINUTES(500); unsigned short long reparingCountDown = MINUTES(5); unsigned int jobtimerCountDown = MINUTES(1); and warning shows: difficult.c:53: warning: (751) arithmetic overflow in constant expression Then I took a look XC8 compiler user guide and it says: This warning can also be triggered by intermediate values overflowing. For example: So I changed my code into: #define MINUTES(x) x*60*1000 //macro unsigned short long UV_CountDown = MINUTES(120u); unsigned short long CVCountDown = MINUTES(130u); unsigned short long WHOLE_CountDown = MINUTES(500u); unsigned short long reparingCountDown = MINUTES(5u); unsigned int jobTimerCountDown = MINUTES(1u); BUT, it's still not working.... then I took a look XC8 compiler user guide again and it says(attachment 1) Question: does suffix u or U support unsigned short long? or I need to change data type from unsigned short long to unsigned long followed by suffix u or U? Attached Image(s) |
|
相关推荐
8个回答
|
|
|
|
|
|
|
|
|
你的乘法数是60000,这比在int中要大,所以它溢出了。在FAQ中遵循建议。
以上来自于百度翻译 以下为原文 You're multiplying 60000 by some number, which is larger than will fit in an int, so it overflows. Follow the suggestions in the FAQ. |
|
|
|
|
|
我在开发业务上有30年的经验,但这是我第一次看到编译器很难让你这么做。
以上来自于百度翻译 以下为原文 I'm 30+ years in the development business, but this is the first time I see Unfortunately the compiler doesn't seem to bash you for this. |
|
|
|
|
|
无符号短长是一个24位对象的XC8 ISM(或者它过去是,我不知道它是否在当前编译器中得到支持)。
以上来自于百度翻译 以下为原文 unsigned short long is an XC8-ism for a 24-bit object (or it used to be, I don't know if it's supported in current compilers). |
|
|
|
|
|
|
|
|
|
|
|
短长已经在XC8和C18中很长一段时间了,仍然是
以上来自于百度翻译 以下为原文 Short long has been in xc8 and c18 For a long time and still is |
|
|
|
|
|
他们试图从版本1.42中的Stdit.h中删除UTIN 24t(AKA无符号短长),有这样的抗议,它在1.43恢复了。
以上来自于百度翻译 以下为原文 They tried to remove uint24_t (aka unsigned short long) from stdint.h in version 1.42 There was such an outcry, it was restored in 1.43 |
|
|
|
|
|
我知道他们从这里取出UTIT24YT,但不知道他们已经恢复了。当时,也有讨论添加64位整数类型。
以上来自于百度翻译 以下为原文 I knew they removed uint24_t from here, but did not know they have restored it. At that time, there were talks of adding 64-bit integer types too. |
|
|
|
|
只有小组成员才能发言,加入小组>>
MPLAB X IDE V6.25版本怎么对bootloader和应用程序进行烧录
485 浏览 0 评论
5806 浏览 9 评论
2346 浏览 8 评论
2234 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3540 浏览 3 评论
1145浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
1114浏览 1评论
我是Microchip 的代理商,有PIC16F1829T-I/SS 技术问题可以咨询我,微信:A-chip-Ti
883浏览 1评论
MPLAB X IDE V6.25版本怎么对bootloader和应用程序进行烧录
489浏览 0评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-9 10:04 , Processed in 0.853492 second(s), Total 86, Slave 69 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
4551