From de7ab5527bcd260a6f6eb35fd07debe1786ab7d4 Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Mon, 20 Jul 2020 08:12:02 -0700 Subject: [PATCH] Avoid -Wdouble-promotion warnings in headers --- include/wx/confbase.h | 2 +- include/wx/graphics.h | 2 +- include/wx/msw/metafile.h | 4 ++-- include/wx/osx/metafile.h | 4 ++-- include/wx/valnum.h | 12 +++++++----- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/include/wx/confbase.h b/include/wx/confbase.h index db98d725e3..5f5d44e8ac 100644 --- a/include/wx/confbase.h +++ b/include/wx/confbase.h @@ -305,7 +305,7 @@ public: { return DoWriteLong(key, value); } bool Write(const wxString& key, float value) - { return DoWriteDouble(key, value); } + { return DoWriteDouble(key, double(value)); } // Causes ambiguities in under OpenVMS #if !defined( __VMS ) diff --git a/include/wx/graphics.h b/include/wx/graphics.h index 04a00db860..be0bfcbccc 100644 --- a/include/wx/graphics.h +++ b/include/wx/graphics.h @@ -279,7 +279,7 @@ class wxGraphicsGradientStop { public: wxGraphicsGradientStop(wxColour col = wxTransparentColour, - float pos = 0.) + float pos = 0.0f) : m_col(col), m_pos(pos) { diff --git a/include/wx/msw/metafile.h b/include/wx/msw/metafile.h index acc9467ea6..961f46687e 100644 --- a/include/wx/msw/metafile.h +++ b/include/wx/msw/metafile.h @@ -146,10 +146,10 @@ private: */ // No origin or extent -bool WXDLLIMPEXP_CORE wxMakeMetafilePlaceable(const wxString& filename, float scale = 1.0); +bool WXDLLIMPEXP_CORE wxMakeMetafilePlaceable(const wxString& filename, float scale = 1.0f); // Optional origin and extent -bool WXDLLIMPEXP_CORE wxMakeMetaFilePlaceable(const wxString& filename, int x1, int y1, int x2, int y2, float scale = 1.0, bool useOriginAndExtent = true); +bool WXDLLIMPEXP_CORE wxMakeMetaFilePlaceable(const wxString& filename, int x1, int y1, int x2, int y2, float scale = 1.0f, bool useOriginAndExtent = true); // ---------------------------------------------------------------------------- // wxMetafileDataObject is a specialization of wxDataObject for metafile data diff --git a/include/wx/osx/metafile.h b/include/wx/osx/metafile.h index 44f139cd23..0b6ac86a83 100644 --- a/include/wx/osx/metafile.h +++ b/include/wx/osx/metafile.h @@ -122,10 +122,10 @@ private: // No origin or extent #define wxMakeMetaFilePlaceable wxMakeMetafilePlaceable -bool WXDLLIMPEXP_CORE wxMakeMetafilePlaceable(const wxString& filename, float scale = 1.0); +bool WXDLLIMPEXP_CORE wxMakeMetafilePlaceable(const wxString& filename, float scale = 1.0f); // Optional origin and extent -bool WXDLLIMPEXP_CORE wxMakeMetaFilePlaceable(const wxString& filename, int x1, int y1, int x2, int y2, float scale = 1.0, bool useOriginAndExtent = true); +bool WXDLLIMPEXP_CORE wxMakeMetaFilePlaceable(const wxString& filename, int x1, int y1, int x2, int y2, float scale = 1.0f, bool useOriginAndExtent = true); // ---------------------------------------------------------------------------- // wxMetafileDataObject is a specialization of wxDataObject for metafile data diff --git a/include/wx/valnum.h b/include/wx/valnum.h index 024c383875..6390a1059d 100644 --- a/include/wx/valnum.h +++ b/include/wx/valnum.h @@ -154,7 +154,7 @@ public: void SetMin(ValueType min) { - this->DoSetMin(min); + this->DoSetMin(static_cast(min)); } ValueType GetMin() const @@ -164,7 +164,7 @@ public: void SetMax(ValueType max) { - this->DoSetMax(max); + this->DoSetMax(static_cast(max)); } ValueType GetMax() const @@ -192,7 +192,7 @@ public: if ( !control ) return false; - control->SetValue(NormalizeValue(*m_value)); + control->SetValue(NormalizeValue(static_cast(*m_value))); } return true; @@ -470,13 +470,15 @@ public: } private: + typedef typename Base::LongestValueType LongestValueType; + void DoSetMinMax() { // NB: Do not use min(), it's not the smallest representable value for // the floating point types but rather the smallest representable // positive value. - this->DoSetMin(-std::numeric_limits::max()); - this->DoSetMax( std::numeric_limits::max()); + this->DoSetMin(static_cast(-std::numeric_limits::max())); + this->DoSetMax(static_cast( std::numeric_limits::max())); } };