完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
你好,我用下面的句子得到了神话“警告751”:UIT88T A=(UIT88T)(65535);事实上,它是一个更复杂的句子,但我正在减少它,试图找到警告的起源,直到我到达这一点,在那里我不知道发生了什么来得到那个警告。高于255的任何值都会触发警告。我面临一些编译器问题吗?有什么建议吗?编译器是XC8 1.41,自由模式。警告等级-3提前感谢。
以上来自于百度翻译 以下为原文 Hello. I got the mythical "warning 751" with the following sentence: uint8_t a = (uint8_t)(65535); In fact it was a much more complex sentence, but I was reducing it to try to find the origin of the warning, until I reached this point, where I have no idea what is happening to get that warning. Any value higher than 255 will trigger the warning. Am I facing some compiler issue? Any suggestion? Compiler is XC8 1.41, Free mode. Warning level -3. Thanks in advance. |
|
相关推荐
3个回答
|
|
您正在将0xFFFF转换为可以容纳max 0xFF的8位类型。当然有溢流。你能理解各种数据类型能容纳什么吗?编译器用户指南会清楚地告诉你。在我的机器上,它位于C:程序文件(x86)Microchip xC8v1.44Doc。
以上来自于百度翻译 以下为原文 You are casting 0xffff to an 8bit type that can hold max 0xff. Of course there's overflow. Do you understand what the various data types can hold? The compiler user guide will tell you clearly. On my machine it's located at C:Program Files (x86)Microchipxc8v1.41docs |
|
|
|
如果你明确地截断一个值,这不是一个溢出。这个问题已经存在很多年了,你会在这里看到关于它的几个线索。您可以在全球范围内降低您的警告级别,或者在特定的情况下使用γ-语用警告。
以上来自于百度翻译 以下为原文 It's not an overflow if you explicitly truncate a value. This issue has been around for many years and you'll see several threads about it here. You can either lower your warning level globally, or use #pragma warning on specific cases. |
|
|
|
我完全知道。这就是放置显式铸造的原因。是的,我总是检查线程来寻找与我的问题相关的一些东西,但是对于编译器是否有问题,我并不清楚(上面的简单句子没有太多的选择)。我需要第二个意见。因此,编译器发行获胜!我必须压制特定的警告…(复杂的句子,结果是固定的和正确的,但警告需要注意,除非编译器试图“太聪明”,就像在这种情况下)。
以上来自于百度翻译 以下为原文 I know perfectly. That's the reason of placing the explicit casting. Yes, I always check threads to find something related to my questions, but it wasn't clear for me if was a compiler issue or not (well with that simple sentence above there is not much to choose). I needed a second opinion. So, compiler issue wins!. I'll have to suppress the specific warnings... (with the complex sentence, result is fixed and correct, but a warning needs attention unless the compiler is trying to be "too smart", like in this case). Cheers mate. |
|
|
|
只有小组成员才能发言,加入小组>>
5162 浏览 9 评论
2000 浏览 8 评论
1928 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3172 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2226 浏览 5 评论
731浏览 1评论
613浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
503浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
629浏览 0评论
527浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-23 03:38 , Processed in 1.371676 second(s), Total 80, Slave 64 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号