Duplicate code generation when having a module defined twice with different crate visibility
In my library I have a C interface in a module. I do not want it to be accessible to Rust code but I want to generate its documentation, so I have the module declared this way
#[cfg(doc)]
pub mod cinterface;
#[cfg(not(doc))]
mod cinterface;
However with cbindgen, it generates me everything twice. To prevent this I've added
[defines]
"doc" = "DOC"
in my cbindgen.toml, but it looks a bit meh to me, as it changes nothing in reality. Would it be possible to configure cbindgen to treat this as a single module and not two?
I think the define shenanigans is the only way to deal with that right now.
You could run the preprocessor on the output to clean it up I guess, or it might be possible to expand the defines config to add "known false/true" defines that we could skip. But that'd require a patch :)