Skip to content

Add deprecation control macros and update MemoryStrategy class#3144

Closed
EricX-Zhao wants to merge 1 commit into
ros2:rollingfrom
EricX-Zhao:add_deprecation_control
Closed

Add deprecation control macros and update MemoryStrategy class#3144
EricX-Zhao wants to merge 1 commit into
ros2:rollingfrom
EricX-Zhao:add_deprecation_control

Conversation

@EricX-Zhao
Copy link
Copy Markdown

Description

Introduces a new deprecation_control.hpp header that provides cross-platform macros (RCLCPP_DEPRECATED and RCLCPP_DEPRECATED_WITH_MSG) for marking class declarations as deprecated, and updates MemoryStrategy to use them.

Background: The standard C++14 [[deprecated]] attribute works portably on functions, variables, and type aliases, but its placement on a class declaration that also carries a visibility macro (e.g., RCLCPP_PUBLIC) is inconsistent across GCC, Clang, and MSVC — no single placement satisfies all three compilers. This was exposed by #3136, which added [[deprecated(...)]] directly to MemoryStrategy.

Minimize code verification

Is this user-facing behavior change?

No behavioral change. Compiler deprecation warnings for MemoryStrategy now work correctly on MSVC in addition to GCC and Clang.

Did you use Generative AI?

With Claude Sonnet 4.6 via Claude Code.

Additional Information

#3142

…ation

Signed-off-by: EricX-Zhao <ericzhao0325@163.com>
@jmachowinski
Copy link
Copy Markdown
Collaborator

GCC11 is not a target compiler for rolling. Could you give more information on why you need support for this ancient platform ?

@EricX-Zhao
Copy link
Copy Markdown
Author

In some embedded devices, the operating system is Ubuntu 22.04 or earlier, and the gcc version is relatively old. Updating to rolling or lyrical versions still requires cross-compilation. This PR has been verified with minimal code to compile successfully on gcc11, gcc15, and MSVC, and deprecated warnings work correctly.

@jmachowinski
Copy link
Copy Markdown
Collaborator

rolling dropped support for 22.04 with the release of lyrical.

@EricX-Zhao
Copy link
Copy Markdown
Author

This PR deprecation_control is like visibility_control that provides cross-platform macros for marking class declarations as deprecated

@jmachowinski
Copy link
Copy Markdown
Collaborator

Using these macros is a step backwards, we go from a standardized construct back to a compiler specific solution. Therefore I am rejecting this PR.

The deprecation has been merged in Lyrical, therefore you could change the PR to just remove all of the MemoryStrategy for rolling. Note, that you will need to also open PRs for the fallout in the other core packages.

@EricX-Zhao
Copy link
Copy Markdown
Author

Thanks for the clarification and I'll close this PR.

@EricX-Zhao EricX-Zhao closed this May 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants