擅长:python、mysql、java
<p>我使用了<a href="http://jakegoulding.com/rust-ffi-omnibus/string_arguments/" rel="nofollow noreferrer">the Rust FFI Omnibus</a>,现在我的代码似乎可以正常工作。在</p>
<pre><code>use std::env;
use std::ffi::{CString, CStr};
use std::os::raw::c_char;
#[no_mangle]
pub extern "C" fn helloworld(names: *const c_char) {
unsafe {
let c_str = CStr::from_ptr(names).to_str().unwrap();
println!("{:?}", c_str);
}
println!("helloworld...");
}
</code></pre>