You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While trying to create a bridge for a message pair containing fields of type bool[], the build of ros1_bridge fails.
The compilation error message:
--- stderr: ros1_bridge
/root/bridge_ws/build/ros1_bridge/generated/sick_safetyscanners2_interfaces__msg__OutputPaths__factories.cpp: In instantiation of ‘void ros1_bridge::streamPrimitiveVector(ros::serialization::OStream&, const VEC_PRIMITIVE_T&) [with VEC_PRIMITIVE_T = std::vector<bool, std::allocator<bool> >]’:
/root/bridge_ws/build/ros1_bridge/generated/sick_safetyscanners2_interfaces__msg__OutputPaths__factories.cpp:208:48: required from here
/root/bridge_ws/build/ros1_bridge/generated/sick_safetyscanners2_interfaces__msg__OutputPaths__factories.cpp:170:36: error: lvalue required as unary ‘&’ operand
170 | memcpy(stream.advance(data_len), &vec.front(), data_len);
/root/bridge_ws/build/ros1_bridge/generated/sick_safetyscanners2_interfaces__msg__OutputPaths__factories.cpp: In instantiation of ‘void ros1_bridge::streamPrimitiveVector(ros::serialization::IStream&, VEC_PRIMITIVE_T&) [with VEC_PRIMITIVE_T = std::vector<bool, std::allocator<bool> >]’:
/root/bridge_ws/build/ros1_bridge/generated/sick_safetyscanners2_interfaces__msg__OutputPaths__factories.cpp:245:48: required from here
/root/bridge_ws/build/ros1_bridge/generated/sick_safetyscanners2_interfaces__msg__OutputPaths__factories.cpp:187:10: error: taking address of rvalue [-fpermissive]
187 | memcpy(&vec.front(), stream.advance(data_len), data_len);
/root/bridge_ws/build/ros1_bridge/generated/sick_safetyscanners2_interfaces__msg__OutputPaths__factories.cpp:187:9: warning: ‘void* memcpy(void*, const void*, size_t)’ writing to an object of type ‘std::vector<bool, std::allocator<bool> >::reference’ {aka ‘struct std::_Bit_reference’} with no trivial copy-assignment; use copy-assignment or copy-initialization instead [-Wclass-memaccess]
187 | memcpy(&vec.front(), stream.advance(data_len), data_len);
| ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/9/vector:68,
from /usr/include/c++/9/functional:62,
from /root/bridge_ws/src/ros1_bridge/include/ros1_bridge/factory.hpp:18,
from /root/bridge_ws/build/ros1_bridge/generated/sick_safetyscanners2_interfaces_factories.hpp:6,
from /root/bridge_ws/build/ros1_bridge/generated/sick_safetyscanners2_interfaces__msg__OutputPaths__factories.cpp:3:
/usr/include/c++/9/bits/stl_bvector.h:72:10: note: ‘std::vector<bool, std::allocator<bool> >::reference’ {aka ‘struct std::_Bit_reference’} declared here
72 | struct _Bit_reference
| ^~~~~~~~~~~~~~
make[2]: *** [CMakeFiles/ros1_bridge.dir/build.make:5431: CMakeFiles/ros1_bridge.dir/generated/sick_safetyscanners2_interfaces__msg__OutputPaths__factories.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [CMakeFiles/Makefile2:292: CMakeFiles/ros1_bridge.dir/all] Error 2
make: *** [Makefile:141: all] Error 2
---
Failed <<< ros1_bridge [11min 49s, exited with code 2]
Steps to reproduce
Simply define a ROS1 message and a ROS2 message with the same package name, same message name, same fields and make sure at least one of the field is of type bool[].
Try to compile ros1_bridge.
Possible reasons for the error
I'm assuming this error has something to do with the fact that a bool in ROS1 is actually a uint8_t and that in ROS2 it is a actual bool.
That plus the fact that std::vector<bool> is a special type of vector, optimized for size (std::_Bit_reference)
Steps to solve?
If somebody can help with ideas on what would be the best way to solve this. I'm assuming that we would have to have some kind of explicit template specialization somewhere to cope with the types bool[].
I'm willing to work on the issue, but some instructions on where to start would be much appreciated
The text was updated successfully, but these errors were encountered:
mendes-jose
changed the title
Build fails for a message pair containing at least a field with type bool[]
Build fails for a message pair containing at least one field of type bool[]Feb 26, 2025
⚠ Relates to #391, #393
Description
While trying to create a bridge for a message pair containing fields of type
bool[]
, the build ofros1_bridge
fails.The compilation error message:
Steps to reproduce
Simply define a ROS1 message and a ROS2 message with the same package name, same message name, same fields and make sure at least one of the field is of type
bool[]
.Try to compile
ros1_bridge
.Possible reasons for the error
I'm assuming this error has something to do with the fact that a
bool
in ROS1 is actually auint8_t
and that in ROS2 it is a actualbool
.That plus the fact that
std::vector<bool>
is a special type ofvector
, optimized for size (std::_Bit_reference
)Steps to solve?
If somebody can help with ideas on what would be the best way to solve this. I'm assuming that we would have to have some kind of explicit template specialization somewhere to cope with the types
bool[]
.I'm willing to work on the issue, but some instructions on where to start would be much appreciated
The text was updated successfully, but these errors were encountered: