-
Notifications
You must be signed in to change notification settings - Fork 328
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
Suitability for opaque-types(-only) FFI types #492
Comments
This seems generally reasonable though I'm not sure I've grasped all the details of what you want. Declaring types as opaque should "just work" if you don't make them repr(C) or such.
Can you clarify? What functions are not getting exported right now (but should)?
We have We could somehow move it to the type declaration instead of the config maybe. |
The issue I'm having with them is that while I don't need access from C to their internals, I need them to be complete. They're used by the C library like this: backendtype_t state;
backend_initialize(&state);
backend_work_on(&state, ...); Making that backendtype_t
The other way 'round: the function signatures are exported, that's something I originally disliked (after all, the canonical signature is in the specified interface that comes from the C library) but now came to appreciate as the duplicate signatures don't hurt but provide additional verification. But then, those types need to match precisely, this means
That helps indeed, thanks, I missed it, that works for me now. As you hinted, I'd prefer to have some declaration inline instead of cbindgen.toml lists, but anyway. There's already the |
Ah, that seems pretty hard to do. Cbindgen doesn't have access to rustc's internals so it can't know the type layout to generate something useful. Plus even if we had it, whatever it generates would be dependent on the rust version that was used at the time, because Rustc could change the layout to its will.
Ah I see... Yeah I find it useful to catch mistakes, fwiw.
Yeah, I think #406 is the right way to address this. |
Just for cross referencing purposes since I've been skimming through related issues, #24 relates to the desire to have a way to automatically generate things like:
|
(working, but not particularly good; for some issues see [492]) [492]: mozilla/cbindgen#492
A library I'm currently binding to Rust (liboscore) has something of a compile-time module system (think back-end, not plug-in; there's only one back-end at a compile time) that works like this:
Is this a use case cbindgen aims to support?
If so, there's a few things I'd need and could attempt to work on (but first is the question of whether this is desirable in the first place):
typedef struct {uint64_t dontuse[16];} oscore_crypto_aead_encryptstate_t;
in there.#[link(name=...)]
(edit: or#[export_name=...]
?) for these types would be convenient, as it would allow the use of rustish type names throughout the code, which only get named mylibrary_mymodule_typename (from TypeName in Rust which has modules/namespaces) at export time.edit: added reference to export_name item
The text was updated successfully, but these errors were encountered: