-
Notifications
You must be signed in to change notification settings - Fork 707
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
Bindgen incorrectly generates pointers to block pointers. #1580
Comments
So seems like all block pointers are const at the moment: rust-bindgen/src/codegen/mod.rs Line 4007 in 8779c91
We should be tracking constness of them already, so this should be trivial to fix (see the usages of Wanna give this a shot? :) |
Hi! If you have any questions regarding this issue, feel free to make a comment here, or ask it in the If you intend to work on this issue, then add |
Thanks for the response @emilio . If I'm understanding correctly, I think the permanent constness of the block pointer itself is fine, as it should exist as an immutable pointer to a block. What's as issue here, I believe, is that both a block pointer as a field, and a pointer to a block pointer as a field, both end up as If I have these two C structs in the header struct x {
void (^val)(int);
};
struct y {
void (^*ptr_val)(int);
}; Bindgen is producing the following (after following the pub struct x {
pub val: *const ::block::Block<(::std::os::raw::c_int,), ()>;
}
pub struct y {
pub ptr_val: *const ::block::Block<(::std::os::raw::c_int,), ()>;
} I've looked into it a bit, and it seems like maybe we want to treat Lines 348 to 358 in 8779c91
Apologies if the initial issue statement was unclear or if I misunderstood your guidance. I have a local patch that fixes and tests this this way, if the above logic seems sane enough. @highfive: assign me |
Hey @gmnicke2! Thanks for your interest in working on this issue. It's now assigned to you! |
Oh you're right, sorry. I misread the example. But you're correct that that canonical type bit is wrong. It's treating blocks the same way as aliases, while it should do that the same way as pointers. That change sounds good, so if you submit a PR with that and a test I'm happy to merge it. Thank you! |
Fixed by #1582, thanks! |
Input C/C++ Header
Bindgen Invocation
Actual Results
Expected Results
Bindgen should produce a struct whose field is a mutable pointer to the block pointer:
The text was updated successfully, but these errors were encountered: