rust-lang / rust-lang/rust-bindgen
MSVC C Integer constants are not supported
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 5.3k
- Forks
- 829
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 15
Description
Input C/C++ Header
#define POOL_FLAG_REQUIRED_START 0x0000000000000001UI64
Bindgen Invocation
builder
.use_core()
.derive_default(true)
.detect_include_paths(false)
.default_enum_style(bindgen::EnumVariation::ModuleConsts)
.parse_callbacks(Box::new(bindgen::CargoCallbacks))
.with_codegen_config(CodegenConfig::VARS)
.generate()
.expect("Bindings should succeed to generate")
.write_to_file(out_path.join("constants.rs"))?
Actual Results
generates empty file
Expected Results
pub const POOL_FLAG_REQUIRED_START: u32 = 1;
It seems like the core issue here is that bindgen does not support msvc's integer constants. Removing the UI64 suffix causes the correct generation. Unfortunately, I do not control the headers I am generating bindings too, so cannot just edit the header to use more standard integer literal declarations.
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
Reproduce the case with the shown C++ header and bindgen::Builder configuration, focusing on CodegenConfig::VARS and the generate entry point. Done means generation succeeds and constants.rs contains POOL_FLAG_REQUIRED_START with value 1 and type u32 for the MSVC UI64 suffix.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, cpp, rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100