From af7bdcafc1e47f974705668627e480d8bb31c8e1 Mon Sep 17 00:00:00 2001 From: EricX-Zhao Date: Sat, 9 May 2026 19:15:00 +0300 Subject: [PATCH] fix(memory_strategy): correct [[deprecated]] attribute placement on class The previous declaration placed the [[deprecated]] attribute between the class-key and the RCLCPP_PUBLIC visibility macro: class RCLCPP_PUBLIC [[deprecated(\"...\")]] MemoryStrategy This form fails to compile under GCC 11.2 because the parser cannot correctly handle a C++ standard attribute followed by a GNU __attribute__ (which RCLCPP_PUBLIC expands to on Linux) in the class head, resulting in errors such as: error: expected primary-expression before 'public' error: expected '}' before 'public' Move the [[deprecated]] attribute to the declaration position, immediately before the class-key. This form is parsed reliably by GCC, Clang, and MSVC, ensures the deprecation warning is actually emitted at use sites, and also propagates to derived classes. Signed-off-by: EricX-Zhao --- rclcpp/include/rclcpp/memory_strategy.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rclcpp/include/rclcpp/memory_strategy.hpp b/rclcpp/include/rclcpp/memory_strategy.hpp index 67e183d03d..ee90ae913b 100644 --- a/rclcpp/include/rclcpp/memory_strategy.hpp +++ b/rclcpp/include/rclcpp/memory_strategy.hpp @@ -39,7 +39,8 @@ namespace memory_strategy * the rmw implementation after the executor waits for work, based on the number of entities that * come through. */ -class RCLCPP_PUBLIC [[deprecated("The executor does not used this anymore")]] MemoryStrategy +[[deprecated("The executor does not used this anymore")]] +class RCLCPP_PUBLIC MemoryStrategy { public: RCLCPP_SMART_PTR_DEFINITIONS_NOT_COPYABLE(MemoryStrategy)