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.47k stars 696 forks source link

Extend `--with-attribute-custom` to support more types #2978

Open jschwe opened 2 days ago

jschwe commented 2 days ago

I would like to use custom attributes to feature guard bindings based on information in the doc comment.

E.g. if the doc comment contains @since 10, i would like to generate

#[cfg(feature = "api-10")]
<the item>

Currently add_attributes seems to only support structs, enums and unions. I would like to also have support for functions and ideally also enum variants. Would a PR that adds function support to add_attributes() be accepted?

CC @mkroening Any technical reason your PR did not implement support for functions, or did you just not need it for your usecase?

mkroening commented 2 days ago

@mkroening Any technical reason your PR did not implement support for functions, or did you just not need it for your usecase?

Nope, no technical reason, I just built off the variants of --with-derive-custom, which do not support functions.