最佳答案
我试图获取一个由 C 库返回的 C 字符串,并通过 FFI 将其转换为 Rust 字符串。
Mylib.c
const char* hello(){
return "Hello World!";
}
水管
#![feature(link_args)]
extern crate libc;
use libc::c_char;
#[link_args = "-L . -I . -lmylib"]
extern {
fn hello() -> *c_char;
}
fn main() {
//how do I get a str representation of hello() here?
}