Skip to content

correct [[deprecated]] attribute placement on class#3142

Open
EricX-Zhao wants to merge 1 commit intoros2:rollingfrom
EricX-Zhao:fix/memory-strategy-deprecated-attribute-placement
Open

correct [[deprecated]] attribute placement on class#3142
EricX-Zhao wants to merge 1 commit intoros2:rollingfrom
EricX-Zhao:fix/memory-strategy-deprecated-attribute-placement

Conversation

@EricX-Zhao
Copy link
Copy Markdown

Description

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.

Is this user-facing behavior change?

No

Did you use Generative AI?

Yes Claude Code Opus4.6

Additional Information

…lass

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 <ericzhao0325@163.com>
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.

1 participant