rust-lang / rust-lang/rust-bindgen
`nullptr_t` bindings name a type that is never defined
Open
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
#include <stddef.h>
nullptr_t ident(nullptr_t p);
int is_null(nullptr_t p);
Bindgen Invocation
$ bindgen input.h --no-rustfmt-bindings --output bindings.rs -- -std=c23
Actual Results
bindgen exits 0 and emits uses of nullptr_t without defining it:
pub type wchar_t = ::std::os::raw::c_int;
pub type max_align_t = f64;
unsafe extern "C" {
pub fn ident(p: nullptr_t) -> nullptr_t;
}
unsafe extern "C" {
pub fn is_null(p: nullptr_t) -> ::std::os::raw::c_int;
}
rustc then fails:
error[E0425]: cannot find type `nullptr_t` in this scope
clang's AST does have the type (BuiltinType 'nullptr_t', plus the stddef.h typedef). Layout is pointer-sized.
Expected Results
Either:
- emit a Rust alias for
nullptr_t(for example*const c_void, which matches the pointer-sized builtin), or - skip these declarations instead of generating code that does not compile.
Environment
bindgen release: 0.72.1
clang: Apple clang 21.0.0 (also reproduced with clang 18 on x86_64-linux)
rustc: 1.97.1
target: aarch64-apple-darwin
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 bindgen invocation with input.h and inspect bindings.rs, then trace how clang's BuiltinType nullptr_t and the stddef.h typedef are represented. Done means the generated bindings compile, either by defining a suitable Rust alias or by skipping the affected declarations; add coverage for this C23 input.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, cpp, rust
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100