Generate Rust function types from C API? #2608
michaeljones
started this conversation in
Ideas
Replies: 2 comments 1 reply
-
This would be really useful for casting the function addresses obtained from dynamic libraries loaded at runtime (using |
Beta Was this translation helpful? Give feedback.
1 reply
-
This sounds like a reasonable but somewhat niche feature. It would be good to have more context about what you're trying to do. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am working on a project which has a plugin system with a C API and some plugins are in Rust and some in C++. The part of the codebase that loads the plugins is in C++ but we're looking to port it to Rust. As a result I'd like to take the definition of the Plugin C API and generate code that'll help me when using
libloading
to load the plugin shared libraries and retrieve symbols from them.From what I can tell, this involves having fn types like:
Rather than function signatures like:
I think it would be useful if bindgen could do that and I don't think it is completely out of the project scope though I'd understand if it is.
I'm quite new to this area so I might be overlooking things. If Rust has a
typeof
style operator then I guess I could get the former from the latter but I don't think that is possible? Maybe it is though.Just an idea as I can't see it in the current configuration. I'd be happy to learn that it is already there. Or maybe there are reasons why it isn't feasible.
Beta Was this translation helpful? Give feedback.
All reactions