Closed GuiyinLi closed 3 months ago
You need to box them or use enums that have #[repr(C)]
or #[repr(u8)]
. Or treat them as opaque and only pass them by pointer (but that's not usable for return types for obvious reasons).
I would like to know if cbindgen can convert the structs from all Rust files in a project into C language (with mutual dependencies between the structs), because currently I can only convert a single Rust file.
It definitely can. If you point it to a lib.rs it should generate all dependent modules. Also if you want dependencies generated there are options for that (parse_deps
, in particular).
How to convert types similar to
Result<usize>
andOption<Arc<SpinLock<my_type>>>
into types in the C language, wheremy_type
is a struct defined in another Rust file(Conversion of Nested Types). Meanwhile, forC
structs used in Rust throughbindings
, can they be directly used as the originalC
structs in theC
language? For example,filp: *mut bindings::file
, can I directly usestruct file
inC
language to replace it?" In addition, I would like to know ifcbindgen
can convert the structs from all Rust files in a project into C language (with mutual dependencies between the structs), because currently I can only convert a single Rust file.