From 7d9eb141af2543e0295638f204d085296e3dd05d Mon Sep 17 00:00:00 2001 From: Gordon McCann Date: Sat, 12 Feb 2022 19:50:48 -0500 Subject: [PATCH] Squash MSVC linker warnings on dll import/export. Make some casts explict to avoid compiler warnings. --- Navigator/src/Navigator/Application.h | 2 +- Navigator/src/Navigator/CutMap.cpp | 2 +- Navigator/src/Navigator/Editor/FileDialog.cpp | 2 +- Navigator/src/Navigator/Editor/SpectrumPanel.cpp | 12 ++++-------- Navigator/src/Navigator/Events/AppEvent.h | 8 ++++---- Navigator/src/Navigator/Histogram.cpp | 6 +++--- Navigator/src/Navigator/Histogram.h | 2 +- Navigator/src/Navigator/NavCore.h | 13 +++++++++++++ Navigator/src/Navigator/Physics/CompassFile.cpp | 2 +- 9 files changed, 29 insertions(+), 20 deletions(-) diff --git a/Navigator/src/Navigator/Application.h b/Navigator/src/Navigator/Application.h index 93c7e02..d6cfced 100644 --- a/Navigator/src/Navigator/Application.h +++ b/Navigator/src/Navigator/Application.h @@ -47,7 +47,7 @@ namespace Navigator { static Application* s_instance; }; - NAV_API Application* CreateApplication(); + Application* CreateApplication(); } #endif \ No newline at end of file diff --git a/Navigator/src/Navigator/CutMap.cpp b/Navigator/src/Navigator/CutMap.cpp index 20caf60..c495a6a 100644 --- a/Navigator/src/Navigator/CutMap.cpp +++ b/Navigator/src/Navigator/CutMap.cpp @@ -73,7 +73,7 @@ namespace Navigator { //Only in ImPlot/ImGui context!!!! void Cut2D::Draw() const { - ImPlot::PlotLine(m_params.name.c_str(), m_xpoints.data(), m_ypoints.data(), m_xpoints.size()); + ImPlot::PlotLine(m_params.name.c_str(), m_xpoints.data(), m_ypoints.data(), (int)m_xpoints.size()); } /* CutMap */ diff --git a/Navigator/src/Navigator/Editor/FileDialog.cpp b/Navigator/src/Navigator/Editor/FileDialog.cpp index 53f7b6d..5f1b551 100644 --- a/Navigator/src/Navigator/Editor/FileDialog.cpp +++ b/Navigator/src/Navigator/Editor/FileDialog.cpp @@ -7,7 +7,7 @@ namespace Navigator { std::string ConvertFileSystemSizeToString(std::uintmax_t value) { int i = 0; - double mantissa = value; + double mantissa = (double)value; for (; mantissa >= 1024.0; ++i) mantissa /= 1024.0; mantissa = std::ceil(mantissa * 10.0) / 10.0; diff --git a/Navigator/src/Navigator/Editor/SpectrumPanel.cpp b/Navigator/src/Navigator/Editor/SpectrumPanel.cpp index 520c9a5..c367f68 100644 --- a/Navigator/src/Navigator/Editor/SpectrumPanel.cpp +++ b/Navigator/src/Navigator/Editor/SpectrumPanel.cpp @@ -26,12 +26,8 @@ namespace Navigator { bool SpectrumPanel::OnImGuiRender(const std::vector& histoList, const std::vector& cutList, const std::vector& paramList) { - //HistogramMap& histMap = HistogramMap::GetInstance(); - //ParameterMap& paramMap = ParameterMap::GetInstance(); - //CutMap& cutMap = CutMap::GetInstance(); static bool acceptCutFlag = false; bool result = false; - //static std::string selectedRegion = ""; if (ImGui::Begin("Active View")) { if (histoList.size() > 0) @@ -66,7 +62,7 @@ namespace Navigator { { m_newCutX.push_back(ImPlot::GetPlotMousePos().x); } - ImPlot::PlotVLines(m_newCutParams.name.c_str(), m_newCutX.data(), m_newCutX.size()); + ImPlot::PlotVLines(m_newCutParams.name.c_str(), m_newCutX.data(), int(m_newCutX.size())); } else if(m_cutModeFlag) @@ -83,7 +79,7 @@ namespace Navigator { m_newCutX.push_back(point.x); m_newCutY.push_back(point.y); } - ImPlot::PlotLine(m_newCutParams.name.c_str(), m_newCutX.data(), m_newCutY.data(), m_newCutX.size()); + ImPlot::PlotLine(m_newCutParams.name.c_str(), m_newCutX.data(), m_newCutY.data(), int(m_newCutX.size())); } if (ImPlot::IsPlotSelected()) { @@ -99,7 +95,7 @@ namespace Navigator { auto& region = m_integralRegions[i]; if (m_zoomedGram.name == region.histogram_name) { - ImPlot::DragRect(i, ®ion.region.X.Min, ®ion.region.Y.Min, ®ion.region.X.Max, ®ion.region.Y.Max, ImVec4(1, 0, 1, 1)); + ImPlot::DragRect(int(i), ®ion.region.X.Min, ®ion.region.Y.Min, ®ion.region.X.Max, ®ion.region.Y.Max, ImVec4(1, 0, 1, 1)); StatResults results = HistogramMap::GetInstance().AnalyzeHistogramRegion(m_zoomedGram.name, region.region); ImPlot::PlotText(GenerateStatString(region.name, results, m_zoomedGram.y_par != "None").c_str(), (region.region.X.Max + region.region.X.Min) * 0.5, (region.region.Y.Min + region.region.Y.Max) * 0.5); @@ -196,7 +192,7 @@ namespace Navigator { auto& region = m_integralRegions[i]; if (spec.name == region.histogram_name) { - ImPlot::DragRect(i, ®ion.region.X.Min, ®ion.region.Y.Min, ®ion.region.X.Max, ®ion.region.Y.Max, ImVec4(1, 0, 1, 1)); + ImPlot::DragRect(int(i), ®ion.region.X.Min, ®ion.region.Y.Min, ®ion.region.X.Max, ®ion.region.Y.Max, ImVec4(1, 0, 1, 1)); } } ImPlot::EndPlot(); diff --git a/Navigator/src/Navigator/Events/AppEvent.h b/Navigator/src/Navigator/Events/AppEvent.h index 7f4b8af..b463deb 100644 --- a/Navigator/src/Navigator/Events/AppEvent.h +++ b/Navigator/src/Navigator/Events/AppEvent.h @@ -18,13 +18,13 @@ namespace Navigator { class NAV_API WindowResizeEvent : public Event { public: - WindowResizeEvent(float x, float y) : + WindowResizeEvent(int x, int y) : m_xSize(x), m_ySize(y) { } - inline float GetXSize() { return m_xSize; } - inline float GetYSize() { return m_ySize; } + inline int GetXSize() { return m_xSize; } + inline int GetYSize() { return m_ySize; } std::string ToString() const override { std::stringstream ss; @@ -36,7 +36,7 @@ namespace Navigator { EVENT_TYPE_SETUP(WindowResize) private: - float m_xSize, m_ySize; + int m_xSize, m_ySize; }; class NAV_API AppUpdateEvent : public Event diff --git a/Navigator/src/Navigator/Histogram.cpp b/Navigator/src/Navigator/Histogram.cpp index e922d76..606d7f9 100644 --- a/Navigator/src/Navigator/Histogram.cpp +++ b/Navigator/src/Navigator/Histogram.cpp @@ -102,7 +102,7 @@ namespace Navigator { if (results.integral == 0) return results; - results.cent_x /= double(results.integral); + results.cent_x /= results.integral; for (int i = bin_min; i <= bin_max; i++) results.sigma_x += m_binCounts[i] * ((m_params.min_x + m_binWidth * i) - results.cent_x) * ((m_params.min_x + m_binWidth * i) - results.cent_x); results.sigma_x = std::sqrt(results.sigma_x / (results.integral - 1)); @@ -208,12 +208,12 @@ namespace Navigator { if (y_min <= m_params.min_y) ybin_max = m_params.nbins_y - 1; else - ybin_max = int((m_params.max_y - y_min)) / m_binWidthY; + ybin_max = int((m_params.max_y - y_min) / m_binWidthY); if (y_max >= m_params.max_y) ybin_min = 0; else - ybin_min = int((m_params.max_y - y_max)) / m_binWidthY; + ybin_min = int((m_params.max_y - y_max) / m_binWidthY); for (int y = ybin_min; y <= ybin_max; y++) { diff --git a/Navigator/src/Navigator/Histogram.h b/Navigator/src/Navigator/Histogram.h index 1a9f7fb..f36b8ec 100644 --- a/Navigator/src/Navigator/Histogram.h +++ b/Navigator/src/Navigator/Histogram.h @@ -7,7 +7,7 @@ namespace Navigator { struct NAV_API StatResults { - int integral = 0.0; + double integral = 0.0; double cent_x = 0.0; double cent_y = 0.0; double sigma_x = 0.0; diff --git a/Navigator/src/Navigator/NavCore.h b/Navigator/src/Navigator/NavCore.h index dedd18b..0bbd5e7 100644 --- a/Navigator/src/Navigator/NavCore.h +++ b/Navigator/src/Navigator/NavCore.h @@ -8,6 +8,19 @@ #else #define NAV_API __declspec(dllimport) #endif + + #ifdef _MSC_VER + #pragma warning (disable: 4127) // condition expression is constant + #pragma warning (disable: 4251) // class 'xxx' needs to have dll-interface to be used by clients of struct 'xxx' // when NAV_API is set to__declspec(dllexport) + #pragma warning (disable: 4091) // '__declspec(dllimport)': ignored on left of class 'xxx' when no variable is declared + #pragma warning (disable: 4996) // 'This function or variable may be unsafe': strcpy, strdup, sprintf, vsnprintf, sscanf, fopen + #if defined(_MSC_VER) && _MSC_VER >= 1922 // MSVC 2019 16.2 or later + #pragma warning (disable: 5054) // operator '|': deprecated between enumerations of different types + #endif + #pragma warning (disable: 26451) // [Static Analyzer] Arithmetic overflow : Using operator 'xxx' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator 'xxx' to avoid overflow(io.2). + #pragma warning (disable: 26495) // [Static Analyzer] Variable 'XXX' is uninitialized. Always initialize a member variable (type.6). + #pragma warning (disable: 26812) // [Static Analyzer] The enum type 'xxx' is unscoped. Prefer 'enum class' over 'enum' (Enum.3). + #endif #else #define NAV_API #endif diff --git a/Navigator/src/Navigator/Physics/CompassFile.cpp b/Navigator/src/Navigator/Physics/CompassFile.cpp index 7a2f707..2fd6f2f 100644 --- a/Navigator/src/Navigator/Physics/CompassFile.cpp +++ b/Navigator/src/Navigator/Physics/CompassFile.cpp @@ -49,7 +49,7 @@ namespace Navigator { m_file->open(m_filename, std::ios::binary | std::ios::in); m_file->seekg(0, std::ios_base::end); - m_size = m_file->tellg(); + m_size = (unsigned int)m_file->tellg(); m_nHits = m_size/24; if(m_size == 0) {