Removing duplicate code from bindgen-generated code

I'm writing bindings for three C libraries that are all related in Rust using bindgen. I've already generated bindings for one of the libraries, but the third library depends on the first library, and in its header it includes the header that I've already generated. Bindgen doesn't know this though, and so it ultimately generates that same header again, in a separate module of my crate. Is there a way I can tell bindgen to ignore types from a given header and then I can use .raw_line() to include a use statement for the dependent module?

If the identifiers from the first library have some common prefix, you can use regex patterns to blacklist them when running bindgen on the third library.

They do, but the third library has a nearly identical prefix. (I'm making FMOD bindings, and FMOD uses FMOD_ for its items, and FMOD studio uses FMOD_STUDIO_/FMOD_Studio_. If I blacklist FMOD_, it'll get rid of FMOD_STUDIO_ too, and I don't want to do that.)

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.