rust-bindgen icon indicating copy to clipboard operation
rust-bindgen copied to clipboard

Make ParseCallbacks::int_macro available to the CLI

Open mystise opened this issue 4 months ago • 4 comments

As per https://github.com/rust-lang/rust-bindgen/issues/3098 and https://github.com/rust-lang/rust-bindgen/issues/3200, currently clang doesn't provide sufficient type information to tell if a macro generated integer is a u64, a u32, or anything else.

As such and until a time when clang does provide the necessary detail, it would be nice to have an override and a fallback option available. Essentially, a fallback type for all integer generating macros, and then individual overrides on a per item basis.

Filing this issue so that it can be tracked separately from the "waiting for clang api changes" issue.

mystise avatar Aug 16 '25 20:08 mystise

Isn't this basically a combo of the existing three options:

  • ParseCallbacks::int_macro (per macro override)
  • default_macro_constant_type (global tweak)
  • fit_macro_constants (global tweak)

Or am I missing something? Please reopen if so.

emilio avatar Aug 31 '25 17:08 emilio

Are those accessible by the CLI? My current experiments have been purely using the CLI, so I don't know about the API surface.

mystise avatar Sep 01 '25 04:09 mystise

--fit-macro-constant-types and --default-macro-constant-type are accessible to the CLI. int_macro could be exposed perhaps.

emilio avatar Sep 01 '25 12:09 emilio

Yeah, adding a per-macro override (exposing int_macro to the CLI) would be a nice feature to have. Also the docs in CLI for --fit-macro-constant-types currently says Try to fit macro constants into types smaller than u32/i32, but I'm assuming that changes to "smaller than 'default'" when setting the default to u64?

I apparently don't have permission to reopen the issue from my end, but I would appreciate this tracking the CLI per macro override.

mystise avatar Sep 01 '25 19:09 mystise