Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Werner compil warning #32

Merged
merged 5 commits into from
Nov 16, 2023
Merged

Werner compil warning #32

merged 5 commits into from
Nov 16, 2023

Conversation

PaddleStroke
Copy link
Contributor

Apply Werner changes manually.

Here are changes I did not implement because I wasn't sure. Please check them.

diff --git a/OndselSolver/Constraint.h b/OndselSolver/Constraint.h
index 3063632..3deadd4 100644
--- a/OndselSolver/Constraint.h
+++ b/OndselSolver/Constraint.h
@@ -21,6 +21,12 @@ namespace MbD {
 		Constraint();
 		Constraint(const char* str);
 
+		using Item::fillConstraints;
+		using Item::fillDispConstraints;
+		using Item::fillEssenConstraints;
+		using Item::fillPerpenConstraints;
+		using Item::fillRedundantConstraints;
+
 		virtual void addToJointForceI(FColDsptr col);
 		virtual void addToJointTorqueI(FColDsptr col);
 		void fillAccICIterJacob(SpMatDsptr mat) override;


diff --git a/OndselSolver/FullColumn.cpp b/OndselSolver/FullColumn.cpp
index b173b08..7a6d801 100644
--- a/OndselSolver/FullColumn.cpp
+++ b/OndselSolver/FullColumn.cpp
@@ -44,7 +44,7 @@ namespace MbD {
         return answer;
     }
     template<typename T>
-    FColsptr<T> FullColumn<T>::times(T a)
+    FColsptr<T> FullColumn<T>::times([[maybe_unused]]T a)
     {
 
diff --git a/OndselSolver/FullRow.h b/OndselSolver/FullRow.h
index 7dfe096..8fde092 100644
--- a/OndselSolver/FullRow.h
+++ b/OndselSolver/FullRow.h
@@ -54,7 +54,7 @@ namespace MbD {
 		return answer;
 	}
 	template<typename T>
-	inline FRowsptr<T> FullRow<T>::times(T a)
+	inline FRowsptr<T> FullRow<T>::times([[maybe_unused]]T a)
 	{
 		assert(false);
 	}

diff --git a/OndselSolver/MBDynBody.h b/OndselSolver/MBDynBody.h
index 99afed4..0ce8d70 100644
--- a/OndselSolver/MBDynBody.h
+++ b/OndselSolver/MBDynBody.h
@@ -13,6 +13,8 @@ namespace MbD {
     class MBDynBody : public MBDynElement
     {
     public:
+        using MBDynElement::parseMBDyn;
+
         void initialize() override;
         void parseMBDyn(std::string line);
         void readMass(std::vector<std::string>& args);

diff --git a/OndselSolver/MBDynJoint.h b/OndselSolver/MBDynJoint.h
index 09dc0fb..a6ed7d2 100644
--- a/OndselSolver/MBDynJoint.h
+++ b/OndselSolver/MBDynJoint.h
@@ -14,6 +14,8 @@ namespace MbD {
     class MBDynJoint : public MBDynElement
     {
     public:
+        using MBDynElement::parseMBDyn;
+
         void initialize() override;
         void parseMBDyn(std::string line);
         void readMarkerI(std::vector<std::string>& args);
diff --git a/OndselSolver/MBDynReference.h b/OndselSolver/MBDynReference.h
index 5867816..3289b49 100644
--- a/OndselSolver/MBDynReference.h
+++ b/OndselSolver/MBDynReference.h
@@ -14,6 +14,8 @@ namespace MbD {
 	class MBDynReference : public MBDynItem
 	{
 	public:
+        using MBDynItem::parseMBDyn;
+
 		void initialize() override;
 		void parseMBDyn(std::string line);
 		void readVelocity(std::vector<std::string>& args);
diff --git a/OndselSolver/MBDynStructural.h b/OndselSolver/MBDynStructural.h
index d38b3d3..7405b28 100644
--- a/OndselSolver/MBDynStructural.h
+++ b/OndselSolver/MBDynStructural.h
@@ -14,6 +14,8 @@ namespace MbD {
     {
     public:
         MBDynStructural();
+        using MBDynNode::parseMBDyn;
+
         void parseMBDyn(std::string line);
         void readVelocity(std::vector<std::string>& args);
         void readOmega(std::vector<std::string>& args);

@wwmayer
Copy link

wwmayer commented Nov 16, 2023

Have you removed the std:: prefix from size_t in Numeric.h? In my patch file it was there and in the PR it is gone and that's why the build fails.

@PaddleStroke
Copy link
Contributor Author

PaddleStroke commented Nov 16, 2023

Sorry I must have missed this one (I had to reapply the changes manually as the dif had conflicts).

@wwmayer
Copy link

wwmayer commented Nov 16, 2023

The [[maybe_unused]] decorator is to fix warnings about unused arguments passed to a function. This is the modern way in C++. The old way is to use e.g. (void)a inside the function body.

The using MBDynItem::parseMBDyn; statements are to fix warnings of the form MBDynReference::parseMBDyn' hides overloaded virtual function [-Woverloaded-virtual]

The warnings are triggered because the arguments of parseMBDyn of the base and subclass are different. So, the method of the sub-class does not override the method of the base class but overloads and hides it.

Now the using MBDynItem::parseMBDyn; prevents the method from being hidden in the subclass. If in client code you want to use the method of the base class then it's directly possible now:

std::vector<std::string> lines;
...
MBDynReference ref;
ref.parseMBDyn(lines);

Without the using statement the above code snippet will raise a compile error that a vector cannot be converted into a string and the only way to call the method of the base class is:

MBDynReference ref;
ref.MBDynItem::parseMBDyn(lines);

@PaddleStroke
Copy link
Contributor Author

Thank you for the explanation @wwmayer !
I will let @aiksiongkoh see how he wants to implement those fixes.

@aiksiongkoh aiksiongkoh merged commit 6f4fca7 into main Nov 16, 2023
@PaddleStroke
Copy link
Contributor Author

PaddleStroke commented Nov 20, 2023

@aiksiongkoh please don't forget the rest of the changes that Werner recommended and that were not in this PR :

diff --git a/OndselSolver/Constraint.h b/OndselSolver/Constraint.h
index 3063632..3deadd4 100644
--- a/OndselSolver/Constraint.h
+++ b/OndselSolver/Constraint.h
@@ -21,6 +21,12 @@ namespace MbD {
 		Constraint();
 		Constraint(const char* str);
 
+		using Item::fillConstraints;
+		using Item::fillDispConstraints;
+		using Item::fillEssenConstraints;
+		using Item::fillPerpenConstraints;
+		using Item::fillRedundantConstraints;
+
 		virtual void addToJointForceI(FColDsptr col);
 		virtual void addToJointTorqueI(FColDsptr col);
 		void fillAccICIterJacob(SpMatDsptr mat) override;


diff --git a/OndselSolver/FullColumn.cpp b/OndselSolver/FullColumn.cpp
index b173b08..7a6d801 100644
--- a/OndselSolver/FullColumn.cpp
+++ b/OndselSolver/FullColumn.cpp
@@ -44,7 +44,7 @@ namespace MbD {
         return answer;
     }
     template<typename T>
-    FColsptr<T> FullColumn<T>::times(T a)
+    FColsptr<T> FullColumn<T>::times([[maybe_unused]]T a)
     {
 
diff --git a/OndselSolver/FullRow.h b/OndselSolver/FullRow.h
index 7dfe096..8fde092 100644
--- a/OndselSolver/FullRow.h
+++ b/OndselSolver/FullRow.h
@@ -54,7 +54,7 @@ namespace MbD {
 		return answer;
 	}
 	template<typename T>
-	inline FRowsptr<T> FullRow<T>::times(T a)
+	inline FRowsptr<T> FullRow<T>::times([[maybe_unused]]T a)
 	{
 		assert(false);
 	}

diff --git a/OndselSolver/MBDynBody.h b/OndselSolver/MBDynBody.h
index 99afed4..0ce8d70 100644
--- a/OndselSolver/MBDynBody.h
+++ b/OndselSolver/MBDynBody.h
@@ -13,6 +13,8 @@ namespace MbD {
     class MBDynBody : public MBDynElement
     {
     public:
+        using MBDynElement::parseMBDyn;
+
         void initialize() override;
         void parseMBDyn(std::string line);
         void readMass(std::vector<std::string>& args);

diff --git a/OndselSolver/MBDynJoint.h b/OndselSolver/MBDynJoint.h
index 09dc0fb..a6ed7d2 100644
--- a/OndselSolver/MBDynJoint.h
+++ b/OndselSolver/MBDynJoint.h
@@ -14,6 +14,8 @@ namespace MbD {
     class MBDynJoint : public MBDynElement
     {
     public:
+        using MBDynElement::parseMBDyn;
+
         void initialize() override;
         void parseMBDyn(std::string line);
         void readMarkerI(std::vector<std::string>& args);
diff --git a/OndselSolver/MBDynReference.h b/OndselSolver/MBDynReference.h
index 5867816..3289b49 100644
--- a/OndselSolver/MBDynReference.h
+++ b/OndselSolver/MBDynReference.h
@@ -14,6 +14,8 @@ namespace MbD {
 	class MBDynReference : public MBDynItem
 	{
 	public:
+        using MBDynItem::parseMBDyn;
+
 		void initialize() override;
 		void parseMBDyn(std::string line);
 		void readVelocity(std::vector<std::string>& args);
diff --git a/OndselSolver/MBDynStructural.h b/OndselSolver/MBDynStructural.h
index d38b3d3..7405b28 100644
--- a/OndselSolver/MBDynStructural.h
+++ b/OndselSolver/MBDynStructural.h
@@ -14,6 +14,8 @@ namespace MbD {
     {
     public:
         MBDynStructural();
+        using MBDynNode::parseMBDyn;
+
         void parseMBDyn(std::string line);
         void readVelocity(std::vector<std::string>& args);
         void readOmega(std::vector<std::string>& args);

aiksiongkoh added a commit that referenced this pull request Nov 27, 2023
* moved misc files to project resource

* MBDyn Sperical Hinge

* Werner compil warning (#32)

* Replace int by size_t in for loops.

* Various dtor missing and some other warning fixes.

* fixed size_t vs int

* fixed size_t vs int

---------

Co-authored-by: Paddle <[email protected]>
Co-authored-by: Aik-Siong Koh <[email protected]>

* moved misc files to project resource

* MBDyn Sperical Hinge

* gravity fix

---------

Co-authored-by: PaddleStroke <[email protected]>
Co-authored-by: Paddle <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants