-
Notifications
You must be signed in to change notification settings - Fork 324
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
feat(ir) Add ability to ignore specific struct fields #579
Conversation
It is now possible to add `/// cbindgen:ignore` on specific struct fields to ignore them. Thus: ``` pub struct OneFieldIgnored { x: i32, /// cbindgen:ignore y: i64, z: i32, } ``` is bound to: ``` typedef struct { int32_t x; int32_t z; } OneFieldIgnored; ```
How is this useful? |
Imagine you have a type But maybe, in Rust, you need to attach some fields to it, like I don't have a usecase for multiple fields actually, just a struct with one field. From the point of view of C, |
Ok, that does make sense to me. Then I think this is the wrong thing to do. An |
Though at that point why marking the struct as |
I agree it makes no sense. Sorry! |
How do you generate an opaque type with cbindgen? |
Generally, by making it not |
I wanted to use this for a union like this:
cbindgen cannot produce anything useful for /// cbindgen:ignore
union U {
a: [u64; 2],
b: u128,
}
union U_FFI {
a: [u64; 2],
} [export]
include = ["U_FFI"]
[export.rename]
U = "U_FFI" |
With this PR, it is now possible to add
/// cbindgen:ignore
on specific struct fields to ignore them.Thus:
is bound to:
It is useful for a project I'm working on, but it can also be helpful for issue like #149.
Thoughts?