feat: add rust link a
This commit is contained in:
5
__ffi/rust_link_a/src/hello.rs
Normal file
5
__ffi/rust_link_a/src/hello.rs
Normal file
@@ -0,0 +1,5 @@
|
||||
/* automatically generated by rust-bindgen 0.56.0 */
|
||||
|
||||
extern "C" {
|
||||
pub fn print_line(str_: *const ::std::os::raw::c_char);
|
||||
}
|
||||
13
__ffi/rust_link_a/src/main.rs
Normal file
13
__ffi/rust_link_a/src/main.rs
Normal file
@@ -0,0 +1,13 @@
|
||||
mod hello;
|
||||
|
||||
use std::ffi::CString;
|
||||
use hello::print_line;
|
||||
|
||||
fn main() {
|
||||
let str = "Hello world!";
|
||||
let c_str = CString::new(str).unwrap();
|
||||
|
||||
unsafe {
|
||||
print_line(c_str.as_ptr());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user