From 64bd331314362d93b43e8df40e0ecd70ad9ba22c Mon Sep 17 00:00:00 2001 From: Martin Geisler Date: Mon, 16 Dec 2024 22:53:54 +0100 Subject: [PATCH] Add speaker notes to interop with C slides (#2496) Part of #1083. --- src/android/interoperability.md | 12 ++++++++++++ src/android/interoperability/with-c.md | 14 ++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/android/interoperability.md b/src/android/interoperability.md index 9436af43..8c116d2a 100644 --- a/src/android/interoperability.md +++ b/src/android/interoperability.md @@ -8,3 +8,15 @@ that you can: When you call functions in a foreign language we say that you're using a _foreign function interface_, also known as FFI. + +
+ +- This is a key ability of Rust: compiled code becomes indistinguishable from + compiled C or C++ code. + +- Technically, we say that Rust can be compiled to the same [ABI] (application + binary interface) as C code. + +
+ +[ABI]: https://en.wikipedia.org/wiki/Application_binary_interface diff --git a/src/android/interoperability/with-c.md b/src/android/interoperability/with-c.md index ad631e66..9991420a 100644 --- a/src/android/interoperability/with-c.md +++ b/src/android/interoperability/with-c.md @@ -24,3 +24,17 @@ We already saw this in the > production. We will look at better options next. + +
+ +- The [`"C"` part][extern-abi] of the `extern` block tells Rust that `abs` can + be called using the C [ABI] (application binary interface). + +- The `safe fn abs` part tells that Rust that `abs` is a safe function. By + default, extern functions are considered unsafe, but since `abs(x)` is valid + for any `x`, we can declare it safe. + +
+ +[extern-abi]: https://doc.rust-lang.org/reference/items/external-blocks.html#abi +[ABI]: https://en.wikipedia.org/wiki/Application_binary_interface