error: narrowing conversion of '4323168000' from 'long int' to 'float' inside { } [-Wnarrowing] }; ^


用QT5编译QT4的工程,这个数4323168000,由long int 转换为 float转换错误。

 narrowing conversion of '4323168000' from 'long int' to 'float' inside { }

翻译:4323168000由long int转换为float 会有收缩的转换  
这个错误有C++11 narrowing 检测并报告
类似的有:error: constant expression evaluates to 1583035200 which cannot be narrowed to type 'float' (在一个float数组中,定义了0xffffffff 1583035200 )

note: insert an explicit cast to silence this issue

转换为float后,会不准确,对于一个costant常数,是不被允许的。可以加强制转换(显示转换)static_cast<float>。

即:{0, static_cast<float>(4294967295U), static_cast<float>(1583035200U)}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM