Interoperability with C
Rust has full support for linking object files with a C calling convention. Similarly, you can export Rust functions and call them from C.
You can do it by hand if you want:
1. ```
unsafe extern "C" {
```
2. ```
safe fn abs(x: i32) -> i32;
```
3. ```
}
```
5. ```
fn main() {
```
6. ```
let x = -42;
```
7. ```
let abs_x = abs(x);
```
8. ```
println!("{x}, {abs_x}");
```
9. ```
}
```
We already saw this in the Safe FFI Wrapper exercise.
This assumes full knowledge of the target platform. Not recommended for production.
We will look at better options next.
