You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A number of C libraries make use of offsetof as a primitive form of reflection. Often this will be exposed as a get_object_foo helpers or used to define _OFFSET constants which are used as part of the API. It would be useful if bindgen could evaluate these expressions and expand them into usize constants.
as far as I can tell. Evaluating offsetof in macros is generally impossible, as macros are context-dependent. Of course you can do somewhat of a best-effort guess, but I wouldn't be in favor of that, plus it'd generally be pretty hacky.
More general macro improvements should be probably directed to the rust-cexpr, though I think realistically this is out of scope for that crate. Stuff like #316 and such should totally be feasible though.
A number of C libraries make use of
offsetof
as a primitive form of reflection. Often this will be exposed as aget_object_foo
helpers or used to define_OFFSET
constants which are used as part of the API. It would be useful if bindgen could evaluate these expressions and expand them intousize
constants.As you probably are aware, Rust does not currently provide a built-in
offset_of
macro which makes it difficult to reproduce this functionality on the Rust side.Input C/C++ Header
Bindgen Invocation
Actual Results
No constant is generated:
/* automatically generated by rust-bindgen */
Expected Results
A
usize
typed constant with the offset of the memberx
instruct Foo
:The text was updated successfully, but these errors were encountered: