-
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
Option to make whitelisting not recursive. #429
Comments
That means that those types are used transitively by the functions you've whitelisted. If you want to make some of those opaque, you can make so with I believe what you want is something like |
Unfortunately not. Then, the types I don't want are still included as u8-array definitions. Also, there seems to be a bug. Without pub struct _bindgen_ty_6 {
pub s: ::types::raw_types::c_int,
pub n: usize,
pub p: *mut mbedtls_mpi_uint,
}
pub use self::_bindgen_ty_6 as mbedtls_mpi;
pub struct _bindgen_ty_7(pub u32);
pub use self::_bindgen_ty_7 as mbedtls_md_type_t; With pub type mbedtls_mpi = [u64; 3usize];
pub use self::u32 as mbedtls_md_type_t; I tried whitelisting |
yep, that last In any case, yeah, I guess we can make whitelisting not recursive (i.e., do not whitelist everything recursively from a whitelisted type). But I think it's easy to understand why that's the default behavior. |
Yes, I think whitelisting non-recursively would fix this. I don't think your previous answer would be a good solution? I'm not sure if I understand exactly what you mean. I want my types to be defined in full, but outside types to come from outside. |
Yes, the solution here is whitelisting non-recursively. |
Or alternatively, adding a set of "externally defined types", but that sounds trickier if it can just be fixed this way. |
Especially with the 'but outside types come from outside' bit, this overlaps the first bullet of #424 ("WIBNI I could tell I currently explicitly blacklist externally defined types, but also would be happy for non-recursive whitelisting to save me the trouble. |
We emit bindings for the transitive closure of whitelisted items because otherwise we would emit bindings referring to types that do not exist and end up with errors when compiling the bindings. If we can successfully avoid emitting bindings for an item in our computed whitelisting transitive closure set, then it is a bug in our computation of that set (ie it shouldn't be emitted because it is not whitelisted itself nor used by a whitelisted item). But it doesn't make sense to "whitelist non-recursively", that leads to emitting bindings with references to types that aren't defined. |
@fitzgen as far as I understand it, that's exactly the point, not defining some types so they can be imported manually :) |
Emitting bindings with "non-existing types" is exactly the point. The types do exist. They're just defined in another crate. |
Isn't blacklisting the specific types we want to leave out from the bindings the proper solution then? |
No, a whitelisting approach makes more sense. There are a lot of types defined in libc. |
Just as a data point - possibly not a terribly helpful one - I'm neutral on this. When I run bindgen in my project, I have exactly 6 types that I want bindgen to ignore, so that I can import them. Few enough that it's no big deal; though the non-recursive whitelisting would also work just fine. I see that in the opening comment in this trail @jethrogb reports having rather more such types to deal with, and I can quite understand that it would be desirable to be able to do that without listing each one explicitly. |
Another follow-up from #21. I'm using
but several libc types are included in the output anyway:
I want bindgen to only output definitions in my project's header files, as in 0.19's match_pat. I will depend on other -sys crates to provide the correct types for those defined outside my project's headers. This is obviously the way it has to be if you want to pass the types around to different -sys crates.
The text was updated successfully, but these errors were encountered: