-
Notifications
You must be signed in to change notification settings - Fork 746
generated function has an argument which shadows a generated static #840
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
Comments
Thanks for the bug report! The best way you can help us resolve this issue with with a reduced test case that demonstrates the bug: https://github.com/servo/rust-bindgen/blob/master/CONTRIBUTING.md#using-creduce-to-minimize-test-cases |
I can see from the error what it's trying to do... Here you got a test-case: static int foo;
struct bar {
int foo: 10;
}; |
btw, I think this shouldn't be a hard error, it's just unfortunate, specially when it works in extern "C" functions. |
Any way to deal with this? 😦 |
I am running in the same issue. Is there anything we can do? |
I think the best solution would be if Bindgen automatically correctly named the static and argument. Statics should be SCREAMING_SNAKE_CASE, and arguments should be snake_case. I did it manually afterwards in the build.rs which resolved it for me: let new_output = [
"ASM",
"UART1",
"UART2",
"CRM",
"AUTO_ADC",
"ADC",
"GPIO_08",
"GPIO_09",
"GPIO_10",
"GPIO_11",
"XTAL32_EXISTS",
"TIMER_WU_EN",
"RTC_WU_EN",
"EXT_WU_EN",
"EXT_WU_EDGE",
"EXT_WU_POL",
"TIMER_WU_IEN",
"RTC_WU_IEN",
"EXT_WU_IEN",
"RTC_WU_EVT",
"EXT_WU_EVT",
"ROSC_EN",
"ROSC_FTUNE",
"ROSC_CTUNE",
"XTAL32_EN",
"XTAL32_GAIN"
].iter()
.fold(bindgen_output, |a, s| {
let lower = s.to_lowercase();
a
.replace(format!("{}: u32", s).as_str(), format!("{}: u32", lower).as_str())
.replace(format!("::core::mem::transmute({})", s).as_str(), format!("::core::mem::transmute({})", lower).as_str())
.replace(format!("{} as u64", s).as_str(), format!("{} as u64", lower).as_str())
}); |
Input C/C++ Header
Perhaps soon.
Bindgen Invocation
Actual Results
Expected Results
Hard to say how I would change this; probably by tweaking the argument name. That seems the simplest, because it only affects one function rather than everyone who wanted to use the static.
The text was updated successfully, but these errors were encountered: