Open basile-henry opened 1 month ago
It looks like std::mem::offset_of isn't supported yet
std::mem::offset_of
src/lib.rs:
src/lib.rs
struct A { a: bool, } pub const offset: usize = std::mem::offset_of!(A, a);
$ cbindgen --config template.toml --crate repro --output my_header.h WARN: Skip repro::offset - (Unsupported expression. Macro(ExprMacro { attrs: [], mac: Macro { path: Path { leading_colon: None, segments: [PathSegment { ident: Ident(std), arguments: None }, Colon2, PathSegment { ident: Ident(mem), arguments: None }, Colon2, PathSegment { ident: Ident(offset_of), arguments: None }] }, bang_token: Bang, delimiter: Paren(Paren), tokens: TokenStream [Ident { sym: A }, Punct { char: ',', spacing: Alone }, Ident { sym: a }] } }))
This seems generally hard because we don't have compiler information. We could try to translate it to an offsetof in C / C++ perhaps tho?
offsetof
It looks like
std::mem::offset_of
isn't supported yetsrc/lib.rs
: