rosidl icon indicating copy to clipboard operation
rosidl copied to clipboard

Python typesupport stores function pointers in capsules, and casting them back to function pointers is only conditionally supported in C++

Open sloretz opened this issue 3 years ago • 1 comments

The generated Python types have PyCapsule attributes called: _CREATE_ROS_MESSAGE, _DESTROY_ROS_MESSAGE, _CONVERT_FROM_PY, and _CONVERT_TO_PY. A PyCapsule accepts a void * so it can be passed around in python and given back to C. The trouble with this is converting from a void * to a function pointer is conditionally supported in C++.

https://stackoverflow.com/questions/27229578/using-reinterpret-cast-to-cast-a-function-to-void-why-isnt-it-illegal https://stackoverflow.com/questions/36645660/why-cant-i-cast-a-function-pointer-to-void https://stackoverflow.com/questions/1096341/function-pointers-casting-in-c

sloretz avatar Mar 19 '21 18:03 sloretz

Indeed. Switching to type erased function pointers should do the trick.

hidmic avatar Mar 19 '21 19:03 hidmic