Skip to content

Commit b07c9ec

Browse files
committed
Fix rolling CI: deprecated subscription callback and -fcoroutines
- Use std::shared_ptr<const MsgT> for subscription callbacks (rolling deprecated the non-const SharedPtr overload) - Only pass -fcoroutines for GCC; Clang enables coroutines by default and warns on the unused flag during clang-tidy
1 parent 80ebcfb commit b07c9ec

4 files changed

Lines changed: 11 additions & 5 deletions

File tree

rclcpp_async/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ if(NOT CMAKE_CXX_STANDARD)
88
endif()
99

1010
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
11-
add_compile_options(-Wall -Wextra -Wpedantic -Werror=deprecated-declarations -fcoroutines)
11+
add_compile_options(-Wall -Wextra -Wpedantic -Werror=deprecated-declarations)
12+
endif()
13+
if(CMAKE_COMPILER_IS_GNUCXX)
14+
add_compile_options(-fcoroutines)
1215
endif()
1316

1417
find_package(ament_cmake REQUIRED)

rclcpp_async/include/rclcpp_async/co_context.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ class CoContext
186186
{
187187
auto stream = std::make_shared<TopicStream<MsgT>>(*this);
188188
stream->sub_ = node_.template create_subscription<MsgT>(
189-
topic, qos, [s = stream](typename MsgT::SharedPtr msg) {
189+
topic, qos, [s = stream](std::shared_ptr<const MsgT> msg) {
190190
if (s->closed_) {
191191
return;
192192
}

rclcpp_async/include/rclcpp_async/topic_stream.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ template <typename MsgT>
3737
class TopicStream
3838
{
3939
CoContext & ctx_;
40-
std::queue<typename MsgT::SharedPtr> queue_;
40+
std::queue<std::shared_ptr<const MsgT>> queue_;
4141
std::coroutine_handle<> waiter_;
4242
typename rclcpp::Subscription<MsgT>::SharedPtr sub_;
4343
bool closed_ = false;
@@ -49,7 +49,7 @@ class TopicStream
4949

5050
struct NextAwaiter
5151
{
52-
using SharedPtr = typename MsgT::SharedPtr;
52+
using SharedPtr = std::shared_ptr<const MsgT>;
5353

5454
TopicStream & stream;
5555
std::stop_token token;

rclcpp_async_example/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ if(NOT CMAKE_CXX_STANDARD)
88
endif()
99

1010
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
11-
add_compile_options(-Wall -Wextra -Wpedantic -Werror=deprecated-declarations -fcoroutines)
11+
add_compile_options(-Wall -Wextra -Wpedantic -Werror=deprecated-declarations)
12+
endif()
13+
if(CMAKE_COMPILER_IS_GNUCXX)
14+
add_compile_options(-fcoroutines)
1215
endif()
1316

1417
find_package(ament_cmake REQUIRED)

0 commit comments

Comments
 (0)