-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[QUESTION] How to write the binding code for a c++ function that takes char * and return a std::string #2615
Comments
Pybind doesn't support pointers-as-arrays in bindings. Wrap that function call in a lambda that:
|
@bstaletic I thought there was an exception for What's the error you get? |
Below is my c++ code:
below is my binding code:
I am getting an error |
@ruiyang00, well, if you read the error, it says you need to pass an argument to the |
@YannickJadoul @rolandd @dekken
In pybind11: |
https://pybind11.readthedocs.io/en/stable/basics.html#creating-bindings-for-a-simple-function
I.e., make sure the function (in the form of a lambda, in your case) you're binding takes a parameter of the right type. pybind11 automatically converts these types for you: https://pybind11.readthedocs.io/en/stable/advanced/cast/strings.html |
@YannickJadoul thank you! I think we can close this Issue! |
Thanks for letting me know, @ruiyang00! :-) |
Hello All, I have a cipher function inside the RC4 class that takes char* and returns std::string. I am wondering how should I write
the binding code. Thank you!!! I am trying return the string to python code. I have searched the Issues, I do not see any solution to my situation!!!
The text was updated successfully, but these errors were encountered: