-
Notifications
You must be signed in to change notification settings - Fork 703
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
Better support for well-known C++ types #738
Comments
I lost last few days trying to read a freaking C++ function returning std::string… to use it from Rust side… STL is a hellhole of complexity… and I've failed :( |
We have a case where, when interacting with Windows, This, of course, is part of a bigger problem of easier mapping to STL types (like |
I'm curious -- what is currently the way to work around issues that arise around these types? For example, I'm currently struggling with a header file that ends up with a
How do I work around this? Marking the type as opaque won't actually prevent bindgen from trying to parse the include file it seems. |
What is the currently recommended way to call a c++ function that wants a std::string argument from rust? |
Two options I'm aware of:
|
I am about to embark on an endeavor to adjust a fork of If this works out (even a little bit) I'll discuss how/whether these changes can be submitted to This will be not be a high priority project for me, so expect not to hear anything for months. But if anyone wants to collaborate, please get in touch! |
I would really appreciate a support for |
Certain types like std::string or std::vector are quite common in C++ code, yet trying to run them through bindgen tends to be a nightmare because their implementations are actually very complicated. There are also types like string_view or llvm::StringRef that are conceptually identical to native Rust types (&str, in this case, sidestepping the issue of UTF-8/non-UTF-8) that would be useful to have represented as the native Rust type in function calls.
Rather than trying to work towards getting all the functionality necessary to build std::string (which is really a complex template that no one uses as such), it makes sense to provide a dedicated mapping mechanism specifically for the std::string type. This could perhaps be done by giving a mechanism to say "where you see type T as a function parameter in C/C++, use RustTy instead for the Rust code" and providing code to map between the C++ and Rust types.
The text was updated successfully, but these errors were encountered: