mirror of
https://github.com/gnu4cn/rust-lang-zh_CN.git
synced 2026-08-19 04:33:27 +08:00
Updated 'src/advanced_features/unsafe.md'.
This commit is contained in:
10
projects/my_rust_lib/Cargo.toml
Normal file
10
projects/my_rust_lib/Cargo.toml
Normal file
@@ -0,0 +1,10 @@
|
||||
[package]
|
||||
name = "my_rust_lib"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[lib]
|
||||
name = "my_rust_lib"
|
||||
crate-type = ["cdylib"]
|
||||
|
||||
[dependencies]
|
||||
9
projects/my_rust_lib/main.c
Normal file
9
projects/my_rust_lib/main.c
Normal file
@@ -0,0 +1,9 @@
|
||||
#include <stdio.h>
|
||||
|
||||
extern void call_from_c();
|
||||
|
||||
int main () {
|
||||
call_from_c();
|
||||
|
||||
return 0;
|
||||
}
|
||||
BIN
projects/my_rust_lib/my_app
Executable file
BIN
projects/my_rust_lib/my_app
Executable file
Binary file not shown.
5
projects/my_rust_lib/src/lib.rs
Normal file
5
projects/my_rust_lib/src/lib.rs
Normal file
@@ -0,0 +1,5 @@
|
||||
#[unsafe(no_mangle)]
|
||||
pub extern "C" fn call_from_c() {
|
||||
println!("刚刚从 C 调用了 Rust 函数!");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user