Skip to content

nullptr_t bindings name a type that is never defined #3437

Description

@lwz23

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions