Binding for only few structures


I want to use a struct X in my rust module which is define in C source. struct is defined in file x.h, where x.h has for tens of structs defined. But i want to generate bindings for only X. is it possible? And i want to ignore multiple header files included in x.h .

Are you looking for Allowlisting - The bindgen User Guide? This allows you to tell bindgen exactly which types, functions, variables and files you want to generate bindings for, and will cause it to ignore everything in x.h that doesn't match an allowlist item.

It will still read everything that x.h includes, since there's no other way to parse a C header file, but it won't generate bindings for anything that doesn't match the allowlist rules.

1 Like

Thanks @farnz for your response. I will try it and let you know.

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.