rust-lang / rust-lang/rust-bindgen
Generation of const pointers
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 5.3k
- Forks
- 829
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 15
Description
Given the following C heder:
const int* foo = ((int*) 3ULL);
bindgen will generate the following Rust code:
/* automatically generated by rust-bindgen 0.71.1 */
unsafe extern "C" {
pub static mut foo: *const ::std::os::raw::c_int;
}
The output I would expect (and need) to be generated is the following:
const FOO: *const c_int = 3usize as *const c_int;
Questions
- Is there any way to configure
bindgento provide the output above? - Is the generation of current output a feature or a bug?
- If it is a feature, what is the rationale behind it?
For context, we are hitting this in the Linux kernel when generating bindings for these kind of pointers.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with the minimal C header shown and compare bindgen's generated Rust binding with the requested const pointer declaration. Review bindgen's handling of initialized const pointer globals and determine whether configuration can select the requested form; done means the behavior and rationale are documented or the generated output is corrected with coverage for this case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, rust
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100