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