From c99ef974a5516973286361f9c1352f5c583674ec Mon Sep 17 00:00:00 2001 From: Hans-Joachim Krauch Date: Fri, 10 Mar 2023 14:25:47 -0300 Subject: [PATCH] Fix exception parameter not being used (#194) ### Public-Facing Changes None ### Description - Enables stricter clang compilation flags - Fix unused exception parameter fixes #193 --- CMakeLists.txt | 11 +++++++---- .../src/ros1_foxglove_bridge_nodelet.cpp | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index efc65dc..980e54a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,10 +15,13 @@ set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) macro(enable_strict_compiler_warnings target) - target_compile_options(${target} PRIVATE - $<$:/WX /W4> - $<$>:-Wall -Wextra -Wpedantic -Werror -Wold-style-cast -Wfloat-equal> - ) + if (MSVC) + target_compile_options(${target} PRIVATE /WX /W4) + elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + target_compile_options(${target} PRIVATE -Wall -Wextra -Wpedantic -Werror -Wold-style-cast -Wfloat-equal -Wmost -Wunused-exception-parameter) + else() + target_compile_options(${target} PRIVATE -Wall -Wextra -Wpedantic -Werror -Wold-style-cast -Wfloat-equal) + endif() endmacro() find_package(nlohmann_json QUIET) diff --git a/ros1_foxglove_bridge/src/ros1_foxglove_bridge_nodelet.cpp b/ros1_foxglove_bridge/src/ros1_foxglove_bridge_nodelet.cpp index 83a8ab5..4022a8f 100644 --- a/ros1_foxglove_bridge/src/ros1_foxglove_bridge_nodelet.cpp +++ b/ros1_foxglove_bridge/src/ros1_foxglove_bridge_nodelet.cpp @@ -453,8 +453,8 @@ class FoxgloveBridge : public nodelet::Nodelet { try { channelPublicationIt->second.publish(msg); } catch (const std::exception& ex) { - ROS_ERROR("Failed to publish message on topic '%s'", - channelPublicationIt->second.getTopic().c_str()); + ROS_ERROR("Failed to publish message on topic '%s': %s", + channelPublicationIt->second.getTopic().c_str(), ex.what()); } }