7.1.1 简单的 C 库
01-简单的 C 库 — Comprehensive Rust
1分钟内可阅读完
译文 · 基于 Comprehensive Rust
原文链接: https://google.github.io/comprehensive-rust/android/interoperability/with-c.html
Rust 完全支持链接使用 C 调用约定的目标文件。同样,你也可以导出 Rust 函数并从 C 调用它们。
若愿意,可以手工完成:
| |
我们在 Safe FFI Wrapper 练习 中已经见过这种写法。
这假设你对目标平台有完整了解。不建议用于生产。
接下来我们看更好的选项。
01-简单的 C 库 — Comprehensive Rust
02-Bindgen — Comprehensive Rust
03-运行二进制 — Comprehensive Rust
04-简单的 Rust 库 — Comprehensive Rust
05-从 C 调用 Rust — Comprehensive Rust