Skip to content

Logging Macros Error with Pointers #1819

@DLu

Description

@DLu

Bug report

Required Info:

  • Operating System: Ubuntu 20.04
  • Installation type: Binaries
  • Version or commit hash: 13.1.0-1focal.20211101.200103
  • DDS implementation: default
  • Client library (if applicable): rclcpp

Steps to reproduce issue

Create a pointer to a rclcpp::Logger

std::shared_ptr<rclcpp::Logger> logger = std::make_shared<rclcpp::Logger>(node->get_logger());

Then try to log something using the dereferenced logger.

RCLCPP_INFO_STREAM(*logger_, "Someday we'll find it, the rainbow connection");

Expected behavior

Logged string!

Actual behavior

Does not compile.

/home/dlu/path/test.cpp: In member function ‘void fake_package::load()’:
/home/dlu/path/test.cpp:132:3: error: ‘class std::shared_ptr<rclcpp::Logger>’ has no member named ‘get_name’
  132 |   RCLCPP_INFO_STREAM(*logger_, "Someday we'll find it, the rainbow connection");
      |   ^~~~~~~~~~~~~~~~~~
/home/dlu/path/test.cpp:132:3: error: ‘class std::shared_ptr<rclcpp::Logger>’ has no member named ‘get_name’
  132 |   RCLCPP_INFO_STREAM(*logger_, "Someday we'll find it, the rainbow connection");
      |   ^~~~~~~~~~~~~~~~~~
make[2]: *** [CMakeFiles/fake_package.dir/build.make:101: CMakeFiles/fake_package.dir/src/test.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:79: CMakeFiles/fake_package.dir/all] Error 2
make: *** [Makefile:141: all] Error 2

Additional information

Surrounding the first argument with parentheses makes it work.

RCLCPP_INFO_STREAM((*logger_), "Someday we'll find it, the rainbow connection");

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions