rust-lang / rust-lang/rust-bindgen
Fails to generate correct code when `UINT64_C` is used
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 5.3k
- Forks
- 829
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 15
Description
I understand that getting the correct integer type from #define is very difficult, however using UINT64_C should clarify to bindgen that it's a 64-bit integer. Currently the macro parser fails on UINT64_C and the Clang macro fallback is needed, but that still generates a 32-bit integer.
Header:
#include <stdint.h>
#define SOMETHING UINT64_C(1)
Without --clang-macro-fallback:
bindgen --allowlist-item SOMETHING header.h
Output:
/* automatically generated by rust-bindgen 0.71.1 */
With --clang-macro-fallback:
bindgen --clang-macro-fallback --allowlist-item SOMETHING header.h
Output:
/* automatically generated by rust-bindgen 0.71.1 */
pub const SOMETHING: u32 = 1;
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 issue with the shown header and bindgen commands, then inspect the macro parser and the Clang macro fallback mentioned in the report. The fix is complete when UINT64_C(1) is recognized without fallback and both command variants generate the correct 64-bit Rust constant type.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, rust
- Domain
- compilers, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100