ros2 / message_filters

BSD 3-Clause "New" or "Revised" License
76 stars 66 forks source link

Resolve ambiguity with boost/bind.hpp #40

Closed sloretz closed 5 years ago

sloretz commented 5 years ago

This resolves an issue where std::bind placeholders are ambiguous when including both boost/bind.hpp and message_filters/signal9.h. boost/bind.hpp includes the line using namespace boost::placeholders;. Message filters also uses using namespace std::placeholders (in a smaller scope). That causes a compile error about the unqualified placeholders (_1, _2, ...) in signal9.h being ambiguous. This PR works around it by using the fully qualified namespace.

My motivation is porting pcl_ros to ROS 2. pcl 1.8 includes boost/bind.hpp in public headers, and pcl_ros uses message_filters.

pcl 1.8 files using boost bind ``` /usr/include/pcl-1.8/pcl/registration/boost.h:#include /usr/include/pcl-1.8/pcl/visualization/boost.h:#include /usr/include/pcl-1.8/pcl/filters/boost.h:#include /usr/include/pcl-1.8/pcl/keypoints/keypoint.h:#include /usr/include/pcl-1.8/pcl/io/boost.h:#include /usr/include/pcl-1.8/pcl/io/openni2/openni2_device.h:#include /usr/include/pcl-1.8/pcl/features/feature.h:#include /usr/include/pcl-1.8/pcl/features/boost.h:#include /usr/include/pcl-1.8/pcl/surface/boost.h:#include ```
Compile errors in pcl_ros ``` /opt/ros/dashing/include/message_filters/signal9.h:281:126: error: reference to ‘_6’ is ambiguous return addCallback(std::function(std::bind(callback, t, _1, _2, _3, _4, _5, _6, _7, _8))); ^~ In file included from /usr/include/boost/function.hpp:13:0, from /usr/include/pcl-1.8/pcl/features/feature.h:48, from /usr/include/pcl-1.8/pcl/features/normal_3d.h:44, from /home/sloretz/ws/mf_ws2/src/perception_pcl/pcl_ros/include/pcl_ros/features/normal_3d.h:41, from /home/sloretz/ws/mf_ws2/src/perception_pcl/pcl_ros/src/pcl_ros/features/normal_3d.cpp:38: /usr/include/c++/7/functional:280:34: note: candidates are: const std::_Placeholder<6> std::placeholders::_6 extern const _Placeholder<6> _6; ^~ In file included from /usr/include/boost/bind/bind.hpp:2319:0, from /usr/include/boost/bind.hpp:22, from /usr/include/pcl-1.8/pcl/features/feature.h:49, from /usr/include/pcl-1.8/pcl/features/normal_3d.h:44, from /home/sloretz/ws/mf_ws2/src/perception_pcl/pcl_ros/include/pcl_ros/features/normal_3d.h:41, from /home/sloretz/ws/mf_ws2/src/perception_pcl/pcl_ros/src/pcl_ros/features/normal_3d.cpp:38: /usr/include/boost/bind/placeholders.hpp:51:38: note: constexpr const boost::arg<6> boost::placeholders::_6 BOOST_STATIC_CONSTEXPR boost::arg<6> _6; ^~ In file included from /opt/ros/dashing/include/message_filters/synchronizer.h:47:0, from /home/sloretz/ws/mf_ws2/src/perception_pcl/pcl_ros/include/pcl_ros/pcl_node.h:60, from /home/sloretz/ws/mf_ws2/src/perception_pcl/pcl_ros/include/pcl_ros/features/feature.h:45, from /home/sloretz/ws/mf_ws2/src/perception_pcl/pcl_ros/include/pcl_ros/features/normal_3d.h:42, from /home/sloretz/ws/mf_ws2/src/perception_pcl/pcl_ros/src/pcl_ros/features/normal_3d.cpp:38: ```

I thought I could work around this by moving message_filters imports above pcl imports, but that does not work. I think the placeholder names are being resolved when the Signal9<> class is instantiated.

sloretz commented 5 years ago

CI (Building all, testing just message_filters)

sloretz commented 5 years ago

CI looks good and approved, merging.