From 678d95ff547e7b3277bdaa8fd74ab45ed1c09b65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Fri, 25 Oct 2024 15:14:56 +0200 Subject: [PATCH] add Werror and fix compile issues --- translation_node/CMakeLists.txt | 2 +- translation_node/src/pub_sub_graph.cpp | 8 ++++++-- translation_node/src/vehicle_attitude_v2.h | 6 ++++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/translation_node/CMakeLists.txt b/translation_node/CMakeLists.txt index c382c18..c33a85a 100644 --- a/translation_node/CMakeLists.txt +++ b/translation_node/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.8) project(translation_node) if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") - add_compile_options(-Wall -Wextra -Wpedantic) + add_compile_options(-Wall -Wextra -Wpedantic -Wno-unused-parameter -Werror) endif() # find dependencies diff --git a/translation_node/src/pub_sub_graph.cpp b/translation_node/src/pub_sub_graph.cpp index e978469..82cc658 100644 --- a/translation_node/src/pub_sub_graph.cpp +++ b/translation_node/src/pub_sub_graph.cpp @@ -140,10 +140,14 @@ void PubSubGraph::updateCurrentTopics(const std::vector &topics) { void PubSubGraph::onSubscriptionUpdate(const Graph::MessageNodePtr& node) { _pub_sub_graph.translate( node, - [](const Graph::MessageNodePtr& node) { + [this](const Graph::MessageNodePtr& node) { if (node->data().publication != nullptr) { - rcl_publish(node->data().publication->get_publisher_handle().get(), + const auto ret = rcl_publish(node->data().publication->get_publisher_handle().get(), node->buffer().get(), nullptr); + if (ret != RCL_RET_OK) { + RCLCPP_WARN_ONCE(_node.get_logger(), "Failed to publish on topic '%s', version: %i", + node->data().topic_name.c_str(), node->data().version); + } } }); diff --git a/translation_node/src/vehicle_attitude_v2.h b/translation_node/src/vehicle_attitude_v2.h index 6dc859c..0f80253 100644 --- a/translation_node/src/vehicle_attitude_v2.h +++ b/translation_node/src/vehicle_attitude_v2.h @@ -24,11 +24,17 @@ class VehicleAttitudeV2Translation { static void fromOlder(const MessageOlder &msg_older, MessageNewer &msg_newer) { // No change in message definition static_assert(sizeof(msg_newer) == sizeof(msg_older)); +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wclass-memaccess" memcpy(&msg_newer, &msg_older, sizeof(msg_newer)); +#pragma GCC diagnostic pop } static void toOlder(const MessageNewer &msg_newer, MessageOlder &msg_older) { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wclass-memaccess" memcpy(&msg_older, &msg_newer, sizeof(msg_newer)); +#pragma GCC diagnostic pop } private: