Skip to content

Commit

Permalink
add Werror and fix compile issues
Browse files Browse the repository at this point in the history
  • Loading branch information
bkueng committed Oct 25, 2024
1 parent 0f041b9 commit 678d95f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion translation_node/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions translation_node/src/pub_sub_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,14 @@ void PubSubGraph::updateCurrentTopics(const std::vector<TopicInfo> &topics) {
void PubSubGraph::onSubscriptionUpdate(const Graph<NodeDataPubSub>::MessageNodePtr& node) {
_pub_sub_graph.translate(
node,
[](const Graph<NodeDataPubSub>::MessageNodePtr& node) {
[this](const Graph<NodeDataPubSub>::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);
}
}
});

Expand Down
6 changes: 6 additions & 0 deletions translation_node/src/vehicle_attitude_v2.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 678d95f

Please sign in to comment.