From 4f1d5fb98edc1edfdce8f4e6430f3b5a47a7c41b Mon Sep 17 00:00:00 2001 From: Chris Lalancette Date: Mon, 18 Mar 2024 09:02:18 -0400 Subject: [PATCH] Fix compiler error with latest compilers. (#1) With the latest compilers (gcc 11 and up), there are errors compiling this package. The compilers warn about variadic macros needing at least one argument. This fixes that warning by making sure that is always the case using a %s specifier. With this in place, the compiler warnings are gone. Signed-off-by: Chris Lalancette --- sophus/common.hpp | 8 ++++---- sophus/se2.hpp | 2 +- sophus/se3.hpp | 2 +- sophus/so2.hpp | 2 +- sophus/so3.hpp | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/sophus/common.hpp b/sophus/common.hpp index 5634d35b0..a89c35a69 100644 --- a/sophus/common.hpp +++ b/sophus/common.hpp @@ -210,22 +210,22 @@ class optional { explicit operator bool() const { return is_valid_; } T const* operator->() const { - SOPHUS_ENSURE(is_valid_, "must be valid"); + SOPHUS_ENSURE(is_valid_, "%s", "must be valid"); return &type_; } T* operator->() { - SOPHUS_ENSURE(is_valid_, "must be valid"); + SOPHUS_ENSURE(is_valid_, "%s", "must be valid"); return &type_; } T const& operator*() const { - SOPHUS_ENSURE(is_valid_, "must be valid"); + SOPHUS_ENSURE(is_valid_, "%s", "must be valid"); return type_; } T& operator*() { - SOPHUS_ENSURE(is_valid_, "must be valid"); + SOPHUS_ENSURE(is_valid_, "%s", "must be valid"); return type_; } diff --git a/sophus/se2.hpp b/sophus/se2.hpp index 5851411b7..911c5bb64 100644 --- a/sophus/se2.hpp +++ b/sophus/se2.hpp @@ -660,7 +660,7 @@ class SE2 : public SE2Base> { /// Precondition: ``i`` must be in 0, 1 or 2. /// SOPHUS_FUNC static Transformation generator(int i) { - SOPHUS_ENSURE(i >= 0 || i <= 2, "i should be in range [0,2]."); + SOPHUS_ENSURE(i >= 0 || i <= 2, "%s", "i should be in range [0,2]."); Tangent e; e.setZero(); e[i] = Scalar(1); diff --git a/sophus/se3.hpp b/sophus/se3.hpp index f65a13e0f..699ed87df 100644 --- a/sophus/se3.hpp +++ b/sophus/se3.hpp @@ -908,7 +908,7 @@ class SE3 : public SE3Base> { /// Precondition: ``i`` must be in [0, 5]. /// SOPHUS_FUNC static Transformation generator(int i) { - SOPHUS_ENSURE(i >= 0 && i <= 5, "i should be in range [0,5]."); + SOPHUS_ENSURE(i >= 0 && i <= 5, "%s", "i should be in range [0,5]."); Tangent e; e.setZero(); e[i] = Scalar(1); diff --git a/sophus/so2.hpp b/sophus/so2.hpp index dcdabd733..d3331dc7b 100644 --- a/sophus/so2.hpp +++ b/sophus/so2.hpp @@ -174,7 +174,7 @@ class SO2Base { using std::hypot; // Avoid under/overflows for higher precision Scalar length = hypot(unit_complex().x(), unit_complex().y()); - SOPHUS_ENSURE(length >= Constants::epsilon(), + SOPHUS_ENSURE(length >= Constants::epsilon(), "%s", "Complex number should not be close to zero!"); unit_complex_nonconst() /= length; } diff --git a/sophus/so3.hpp b/sophus/so3.hpp index 67dd852fd..dd56067c0 100644 --- a/sophus/so3.hpp +++ b/sophus/so3.hpp @@ -693,7 +693,7 @@ class SO3 : public SO3Base> { /// SOPHUS_FUNC static SO3 expAndTheta(Tangent const& omega, Scalar* theta) { - SOPHUS_ENSURE(theta != nullptr, "must not be nullptr."); + SOPHUS_ENSURE(theta != nullptr, "%s", "must not be nullptr."); using std::abs; using std::cos; using std::sin; @@ -759,7 +759,7 @@ class SO3 : public SO3Base> { /// Precondition: ``i`` must be 0, 1 or 2. /// SOPHUS_FUNC static Transformation generator(int i) { - SOPHUS_ENSURE(i >= 0 && i <= 2, "i should be in range [0,2]."); + SOPHUS_ENSURE(i >= 0 && i <= 2, "%s", "i should be in range [0,2]."); Tangent e; e.setZero(); e[i] = Scalar(1);