Closed kornelski closed 6 years ago
That is expected. You're supposed to be using the whitelisting / blacklisting bits which should leave out everything unneeded. In this case you'd call bindgen like binden input.h --whitelist-type Foo
. Is that not working for some reason?
When I make bindings for 3rd party code I don't know all the types. I'd rather allow/block by directory (e.g. everything from ./vendor/
, nothing from /usr/
).
Because of documentation error (#1214) I thought whitelisting would be unusable, but with regex support the whitelist workflow is not too bad. It's just I didn't expect it to be necessary, and hoped for the default invocation to be smarter.
Right, whitelisting by directory was considered and it's not fun. For easy cases it's fine, but given you can declare the same type in multiple places, and then not define it, it can be unclear which directory a type belongs to.
@kornelski I'm trying to understand how you actually solved this problem. Do you have an example of how you removed all things Darwin from the generated code?
I haven't solved it. I've closed the issue because @emilio's comment sounded like it's a "wontfix" problem.
Bindgen still generates unwanted symbols, and I just delete the garbage by hand.
For some things I've also used my citrus, which can filter out system header symbols better.
Ahh. Ok. Got it. Thanks for responding.
Input C/C++ Header
Bindgen Invocation
on macOS High Sierra.
Actual Results
Expected Results
i.e. include of system headers should not cause any output, unless some type from the header is actually used. Then it should only pull definition of that type, rather than open floodgates to whatever the OS puts in there. Total blacklisting of all items from all system headers would be fine, too. I prefer to add them from the libc crate.
This is a problem, because:
it exposes definitions that are private to the OS. They're unstable and non-portable, and aren't supposed to be the part of an API that a
-sys
crate exposes.there's a lot of them. It's very time consuming and error prone to delete them to leave only relevant bits.