Skip to content

Deprecated subscription callback signatures are still compiling #2972

@mini-1235

Description

@mini-1235

Generated by Generative AI

No

Operating System:

Linux mini1235-XPS-15-9520 6.8.0-86-generic #87-Ubuntu SMP PREEMPT_DYNAMIC Mon Sep 22 18:03:36 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux

ROS version or commit hash:

Rolling

RMW implementation (if applicable):

No response

RMW Configuration (if applicable):

No response

Client library (if applicable):

No response

'ros2 doctor --report' output

ros2 doctor --report
<COPY OUTPUT HERE>

Steps to reproduce issue

  1. Create subscription with deprecated syntax
sub_ = this->create_subscription<std_msgs::msg::Int32>(
      input,
      10,
      [](std::shared_ptr<std_msgs::msg::Int32> msg)

Expected behavior

Reports error or warning when compile

Actual behavior

Nothing happen

Additional information

https://docs.ros.org/en/rolling/Releases/Release-Jazzy-Jalisco.html#deprecated-subscription-callback-signatures-were-removed

states that

Back in Humble, subscription signatures of the form void callback(std::shared_ptr<MessageT>) and void callback(std::shared_ptr<MessageT>, const rclcpp::MessageInfo &) were deprecated.

In Jazzy, these subscription signatures have been removed.
Users should switch to using void callback(std::shared_ptr<const MessageT>) or void callback(std::shared_ptr<const MessageT>, const rclcpp MessageInfo &).

Related PRs in this repo are:

In the latest version, I am still able to use the syntax std::shared_ptr<MessageT> in the callback, is this intended?
If no, why don't we remove the deprecated signature as well?

// Deprecated signatures:
using SharedPtrCallback =
std::function<void (std::shared_ptr<SubscribedType>)>;
using SharedPtrROSMessageCallback =
std::function<void (std::shared_ptr<ROSMessageType>)>;
using SharedPtrWithInfoCallback =
std::function<void (std::shared_ptr<SubscribedType>, const rclcpp::MessageInfo &)>;
using SharedPtrWithInfoROSMessageCallback =
std::function<void (
std::shared_ptr<ROSMessageType>,
const rclcpp::MessageInfo &)>;
using SharedPtrSerializedMessageCallback =
std::function<void (std::shared_ptr<rclcpp::SerializedMessage>)>;
using SharedPtrSerializedMessageWithInfoCallback =
std::function<void (std::shared_ptr<rclcpp::SerializedMessage>, const rclcpp::MessageInfo &)>;

This is something I noticed in ros2/ros2_documentation#2333 (comment), where the ros2/demos#532 changes from const sensor_msgs::msg::Image::SharedPtr to sensor_msgs::msg::Image::ConstSharedPtr and breaks the tutorial

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions