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. + +<details> + +- 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. + +</details> + +[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. + +<details> + +- 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. + +</details> + +[extern-abi]: https://doc.rust-lang.org/reference/items/external-blocks.html#abi +[ABI]: https://en.wikipedia.org/wiki/Application_binary_interface