Bindgen not generating bindings for functions

I am trying to generate some Rust bindings for the following library, written in C:

I have followed the tutorial and managed to get a .rs file that contains the bindings. While the structs are "converted" correctly, the various functions needed to use the library (such as dz_init, dz_extend, etc.) are not, as they do not appear at all in the resulting file.

Am I doing something wrong?

These are static functions which have private visibility outside of translation units. They have several advantages such as defining a function in the header. However that means that the header needs a .c or .cpp file.
Apparently bindgen doesn’t support translating static or static inline functions:

Even if it did, it means bindgen needs to produce a C file which includes the header and generate a C lib, and even then, linkage is still internal and will not work if you link it to a Rust lib.

Bindgen is for linking to functions in libraries, but these functions don't exist in a library. They exist only in the C header, and it's not possible to link to them.

You can write a wrapper.c file that includes the header file and has your exported functions that call the non-exported static functions, and then compile and link it with the cc crate.

Or use c2rust to convert these functions to Rust and put them in your crate.

Thanks for your answers @MoAlyousef and @kornel, ultimately I decided not to create bindings for this specific library. After switching to another one, I was able to generate bindings without issues.

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.