Hello, I got stuck in solving one problem. I need a DLL for interop and Rust function can have only this syntax:
pub extern "C" fn vfp_test12(
input: *mut c_char,
output: *mut c_char
) -> *const c_char {
}```
Output parameter is C char* pointer and I need to change pointing data to sort of string.
I found this unsafe solution:
unsafe {
let output_value = std::ffi::CString::new("ABCD123456789").unwrap();
std::ptr::copy_nonoverlapping(output_value.as_ptr(), output as *mut i8, output_value.as_bytes().len() + 1);
}```
Is it good solution or crap?
I cannot use *mut *mut c_char for output, because DLL consument cannot bind this kind of syntax...