rust-lang / rust-bindgen

Automatically generates Rust FFI bindings to C (and some C++) libraries.
https://rust-lang.github.io/rust-bindgen/
BSD 3-Clause "New" or "Revised" License
4.4k stars 691 forks source link

allowlist_item does not work for anonymous enums - allowlist_var does #2826

Closed hkonetzky closed 5 months ago

hkonetzky commented 5 months ago

Input C/C++ Header

enum
{
  BASS_FX_BFX_ROTATE = 0x10000
  BASS_FX_BFX_ECHO,
  BASS_FX_BFX_FLANGER
};

Bindgen Invocation

$ bindgen input.h --allowlist-item "BASS.*" -o output.rs

Actual Results

empty file - apart from the bindgen comment

one warning is outputted by bindgen: bindgen::ir::context] unused option: --allowlist-items BASS.*

Expected Results

consts generated like this (works when omitting the allowlist-items flag or using allowlist-var instead):

/* automatically generated by rust-bindgen 0.69.4 */

pub const BASS_FX_BFX_ROTATE: _bindgen_ty_1 = 65536;
pub const BASS_FX_BFX_ECHO: _bindgen_ty_1 = 65537;
pub const BASS_FX_BFX_FLANGER: _bindgen_ty_1 = 65538;
pub type _bindgen_ty_1 = ::std::os::raw::c_int;
pvdrz commented 5 months ago

Thanks for the report!

It seems that anonymous enums need some special casing that was overlooked when --allowlist-item was implemented.