Open
Description
It seems that while bindgen respects preprocessor defines passed through clang for evaluating ifdefs, it does not consider them for processing #define
directives.
While the obvious workaround (or rather perhaps, the preferred way) is to put these defines in a wrapper.h
header instead of passing them as arguments to clang, I stumbled over this after thinking that I do not need a wapper.
Regardless, it might be a good idea to mention this in Create a wrapper.h Header.
Input C/C++ Header
#define FOO_A 7
#ifdef FOO_FROM_CLANG
#define FOO_B 3
#endif
#define FOO_C (FOO_FROM_CLANG)
#define FOO_D (FOO_FROM_CLANG + 1)
Bindgen Invocation
$ bindgen input.h -- -DFOO_FROM_CLANG=3
Actual Results
/* automatically generated by rust-bindgen 0.63.0 */
pub const FOO_A: u32 = 7;
pub const FOO_B: u32 = 3;
Expected Results
All defines based off defines provided through clang show up in the generated bindings:
/* automatically generated by rust-bindgen 0.63.0 */
pub const FOO_A: u32 = 7;
pub const FOO_B: u32 = 3;
pub const FOO_C: u32 = 7;
pub const FOO_D: u32 = 8;
Metadata
Metadata
Assignees
Labels
No labels