Description
I prefer to generate my FFI code once and then distribute that, rather than generate it at build time. I see that you recommend the opposite, but even so: I expect that plenty of my potential users - especially on Windows - won't have the required dependencies installed. Better for me to figure out once how to get bindgen
working, and be done with it.
At the moment, though, I have to do a little massaging of the code produced by bindgen
to make it portable. My life would be that little bit easier if bindgen
could be persuaded to produce portable output in the first place.
Ways in which I currently hand-modify output, and suggestions as to how this might be avoided:
-
The exact definition of various types defined in system headers varies. So I blacklist them, and then modify the autogenerated code to import a portable version of those types eg
use libc::timeval
- WIBNI I could tell
bindgen
where to get a type from
- WIBNI I could tell
-
One consequence of this is that
Debug
can be wrongly derived. Eg it is derived on a structure containing anin_addr
, which I obtain aslibc::in_addr
, which doesn't implementDebug
.- (Actually
libc::in_addr
probably should beDebug
- derive Debug on structures? libc#302). - But it isn't, so I have to manually un-derive
Debug
for structures that contain it - WIBNI bindgen didn't assume that things that it didn't know about (or which were blacklisted) were
Debug
- (Actually
-
autogenerated testcases all assume that pointer size is per the machine on which they were generated. So I delete them.
- WIBNI I could tell
bindgen
to not generate such testcases
- WIBNI I could tell
None of this is a big deal for me - bindgen
is great and the work I just described really isn't very much. Feel free to close this out if it's not of interest to you!