Dushistov / flapigen-rs

Tool for connecting programs or libraries written in Rust with other languages
BSD 3-Clause "New" or "Revised" License
775 stars 59 forks source link

FFI Compatible structs #453

Closed owenshoemaker closed 10 months ago

owenshoemaker commented 10 months ago

Is it possible to return an FFI compatible struct from a foreign_class method? I have tried a number of approaches and haven't had any success and can't find any documentation.

I am just trying to return something like this:

[repr(C)]

pub struct SimpleStruct { pub my_string: *const c_char, }

I just get the "Do not know conversion from such rust type" error.

Dushistov commented 10 months ago

You can find example here:

https://github.com/Dushistov/flapigen-rs/blob/c74d48439895ae7394990b771a5acde54e309bfe/cpp_tests/src/cpp_glue.rs.in#L970

owenshoemaker commented 10 months ago

That did the trick. I just needed to use: "*const ::std::os::raw::c_char".

Thanks!