MSVC: Fix compiler warnings

* avoid redefines in Assembly
* explicit cast from size_t to int
* remove unused variables
* avoid implicit cast from double to float
* in test cases replace EXPECT_FLOAT_EQ with EXPECT_DOUBLE_EQ or EXPECT_NEAR when doubles are used
This commit is contained in:
wmayer
2024-06-20 17:41:02 +02:00
committed by Chris Hennes
parent d2be7f7d89
commit 2f8382ae59
9 changed files with 70 additions and 64 deletions

View File

@@ -72,6 +72,11 @@ SET(AssemblyGuiIcon_SVG
)
add_library(AssemblyGui SHARED ${AssemblyGui_SRCS} ${AssemblyGuiIcon_SVG})
if(WIN32)
target_compile_definitions(AssemblyGui PRIVATE _USE_MATH_DEFINES)
endif(WIN32)
target_link_libraries(AssemblyGui ${AssemblyGui_LIBS})
if (FREECAD_WARN_ERROR)
target_compile_warn_error(AssemblyGui)

View File

@@ -21,8 +21,8 @@
* *
***************************************************************************/
#ifndef POINTSGUI_PRECOMPILED_H
#define POINTSGUI_PRECOMPILED_H
#ifndef ASSEMBLYGUI_PRECOMPILED_H
#define ASSEMBLYGUI_PRECOMPILED_H
#include <FCConfig.h>
@@ -30,6 +30,7 @@
// STL
#include <algorithm>
#include <cmath>
#include <limits>
#include <memory>
@@ -53,4 +54,4 @@
#endif //_PreComp_
#endif // POINTSGUI_PRECOMPILED_H
#endif // ASSEMBLYGUI_PRECOMPILED_H

View File

@@ -38,7 +38,7 @@ EndMill::EndMill(const std::vector<float>& toolProfile, int toolid, float diamet
profilePoints = nullptr;
mHandleAllocation = false;
int srcBuffSize = toolProfile.size();
int srcBuffSize = static_cast<int>(toolProfile.size());
nPoints = srcBuffSize / 2;
if (nPoints < 2) {
return;

View File

@@ -398,7 +398,7 @@ Base::Vector3d ViewProviderMeasureBase::getTextDirection(Base::Vector3d elementD
Gui::View3DInventor* view = nullptr;
try {
view = dynamic_cast<Gui::View3DInventor*>(this->getActiveView());
} catch (const Base::RuntimeError& e) {
} catch (const Base::RuntimeError&) {
Base::Console().Log("ViewProviderMeasureBase::getTextDirection: Could not get active view\n");
}
@@ -430,7 +430,7 @@ bool ViewProviderMeasureBase::isSubjectVisible()
Gui::Document* guiDoc = nullptr;
try {
guiDoc = this->getDocument();
} catch (const Base::RuntimeError& e) {
} catch (const Base::RuntimeError&) {
Base::Console().Log("ViewProviderMeasureBase::isSubjectVisible: Could not get document\n");
return false;
}
@@ -550,7 +550,7 @@ ViewProviderMeasure::ViewProviderMeasure()
Gui::View3DInventor* view = nullptr;
try {
view = dynamic_cast<Gui::View3DInventor*>(this->getActiveView());
} catch (const Base::RuntimeError& e) {
} catch (const Base::RuntimeError& ) {
Base::Console().Log("ViewProviderMeasure::ViewProviderMeasure: Could not get active view\n");
}
@@ -581,7 +581,7 @@ void ViewProviderMeasure::positionAnno(const Measure::MeasureBase* measureObject
Gui::View3DInventor* view = nullptr;
try {
view = dynamic_cast<Gui::View3DInventor*>(this->getActiveView());
} catch (const Base::RuntimeError& e) {
} catch (const Base::RuntimeError&) {
Base::Console().Log("ViewProviderMeasure::positionAnno: Could not get active view\n");
}

View File

@@ -81,9 +81,9 @@ namespace TechDrawGui
//internal helper functions
TechDraw::LineFormat& _getActiveLineAttributes();
Base::Vector3d _circleCenter(Base::Vector3d p1, Base::Vector3d p2, Base::Vector3d p3);
void _createThreadCircle(const std::string Name, TechDraw::DrawViewPart* objFeat, float factor);
void _createThreadCircle(const std::string Name, TechDraw::DrawViewPart* objFeat, double factor);
void _createThreadLines(const std::vector<std::string>& SubNames, TechDraw::DrawViewPart* objFeat,
float factor);
double factor);
void _setLineAttributes(TechDraw::CosmeticEdge* cosEdge);
void _setLineAttributes(TechDraw::CenterLine* cosEdge);
void _setLineAttributes(TechDraw::CosmeticEdge* cosEdge, int style, float weight, App::Color color);
@@ -2113,7 +2113,7 @@ Base::Vector3d _circleCenter(Base::Vector3d p1, Base::Vector3d p2, Base::Vector3
return Base::Vector3d(center.x, center.y, 0.0);
}
void _createThreadCircle(const std::string Name, TechDraw::DrawViewPart* objFeat, float factor)
void _createThreadCircle(const std::string Name, TechDraw::DrawViewPart* objFeat, double factor)
{
constexpr double ArcStartDegree{255.0};
constexpr double ArcEndDegree{165.0};
@@ -2138,7 +2138,7 @@ void _createThreadCircle(const std::string Name, TechDraw::DrawViewPart* objFeat
}
void _createThreadLines(const std::vector<std::string>& SubNames, TechDraw::DrawViewPart* objFeat,
float factor)
double factor)
{
// create symbolizing lines of a thread from the side seen
std::string GeoType0 = TechDraw::DrawUtil::getGeomTypeFromName(SubNames[0]);