Suppression of Implicit Conversion warnings
-
I am running the current version of QtCreator on a Mac with the current version of Xcode.
When I compile a program with the following line,
int x = round(1.1);
I receive a warning that states:
"implicit conversion turns floating-point number to integer; 'double' to 'int'"
How may I suppress such warnings?
Thank you.
Hoyt
-
Hi,
What about using
std::rint
? -
SGaist,
The line
x = std::rint(1.1);
generates the same warning.
"implicit conversion turns floating-point number into integer: 'double' to 'int'"
I would like to turn off all "implicit conversion" warnings.
Hoyt
@Hoyt
Hi
Why not use
std::lround(); ( Lround)
If you want to round to nearest int.Google says you can hide these warnings you can switch “implicit conversion to 32 bit type” to no in your build settings. Might only affect other converts and not double to int truncating.
Not that i recommend it as it will also hide the cases where it does matter :) -
mrjj,
I receive another implicit conversion with std::lround()
I can solve the problem by using static_cast<int> . I guess that I will utilize casting to eliminate the warnings.
Hoyt