From c5d8386af58d976d5698edf0ae8e6226ffac2552 Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Sat, 15 Jul 2023 15:56:33 +0000 Subject: [PATCH] Fix Windows compiler warnings Signed-off-by: Michael Carroll --- examples/color_example.cc | 13 ++++++------- include/gz/math/Helpers.hh | 4 ++-- include/gz/math/Polynomial3.hh | 2 +- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/examples/color_example.cc b/examples/color_example.cc index 8d0419234..fe52eac54 100644 --- a/examples/color_example.cc +++ b/examples/color_example.cc @@ -18,18 +18,17 @@ #include #include -int main(int argc, char **argv) +int main(int /*argc*/, char **/*argv*/) { //! [Create a color] - gz::math::Color a = gz::math::Color(0.3, 0.4, 0.5); + gz::math::Color a = gz::math::Color(0.3f, 0.4f, 0.5f); //! [Create a color] // The channel order is R, G, B, A and the default alpha value of a should be 1.0 std::cout << "The alpha value of a should be 1: " << a.A() << std::endl; - - + //! [Set a new color value] - a.gz::math::Color::Set(0.6, 0.7, 0.8, 1.0); + a.gz::math::Color::Set(0.6f, 0.7f, 0.8f, 1.0f); //! [Set a new color value] std::cout << "The RGBA value of a: " << a << std::endl; @@ -41,8 +40,8 @@ int main(int argc, char **argv) //! [Math operator] std::cout << "Check if a is Blue: " << (a == gz::math::Color::Blue) << std::endl; - std::cout << "The RGB value of a should be (0, 0, 1): " << a[0] << ", " - << a[1] << ", " + std::cout << "The RGB value of a should be (0, 0, 1): " << a[0] << ", " + << a[1] << ", " << a[2] << std::endl; //! [Math operator] diff --git a/include/gz/math/Helpers.hh b/include/gz/math/Helpers.hh index 6cda53455..609c97ad9 100644 --- a/include/gz/math/Helpers.hh +++ b/include/gz/math/Helpers.hh @@ -353,7 +353,7 @@ namespace gz T sum = 0; for (unsigned int i = 0; i < _values.size(); ++i) sum += _values[i]; - return sum / _values.size(); + return sum / static_cast(_values.size()); } /// \brief Get the variance of a vector of values. @@ -367,7 +367,7 @@ namespace gz T sum = 0; for (unsigned int i = 0; i < _values.size(); ++i) sum += (_values[i] - avg) * (_values[i] - avg); - return sum / _values.size(); + return sum / static_cast(_values.size()); } /// \brief Get the maximum value of vector of values. diff --git a/include/gz/math/Polynomial3.hh b/include/gz/math/Polynomial3.hh index ac64439d4..43971bcfb 100644 --- a/include/gz/math/Polynomial3.hh +++ b/include/gz/math/Polynomial3.hh @@ -229,7 +229,7 @@ namespace gz using std::abs; // enable ADL const T magnitude = abs(this->coeffs[i]); const bool sign = this->coeffs[i] < T(0); - const int exponent = 3 - i; + const int exponent = 3 - static_cast(i); if (magnitude >= epsilon) { if (streamStarted)