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
Pybind11 is decent at binding C-only libraries, but one thing where it can be painful is in converting C error codes into C++ exceptions. Currently the only way I know of to do this is using lambdas, but this means you have to write out the parameters of the C function you're wrapping in a lambda which is inconvenient.
What I would like to have is an ability to pass a function when making a C++ function available from Python.
This function would be called with the bound functions unconverted return value, and could either convert it to something else or consume it, such as an error code which this function would throw as a C++ exception.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Pybind11 is decent at binding C-only libraries, but one thing where it can be painful is in converting C error codes into C++ exceptions. Currently the only way I know of to do this is using lambdas, but this means you have to write out the parameters of the C function you're wrapping in a lambda which is inconvenient.
What I would like to have is an ability to pass a function when making a C++ function available from Python.
This function would be called with the bound functions unconverted return value, and could either convert it to something else or consume it, such as an error code which this function would throw as a C++ exception.
Beta Was this translation helpful? Give feedback.
All reactions