Step Into Rust · Lesson 11 · Systems Rust
FFI: Talking to C
extern blocks, C strings, callbacks into Rust, and wide strings for Windows.
- ~35 minreading and coding
- 4missions
- membersaccess
- Rustlanguage
Part of Step Into Rust. The full lesson, its missions and the real compiler and debugger are in the course. Try a free lesson first to see how it works.
Rust can call any function that uses the C calling convention. You declare it in an extern block, and every call is unsafe, because the compiler can't check what the C side does:
In this lesson
- The foreign function interface
- C strings
- Callbacks
- Windows: extern "system" and wide strings
Missions
- Call C functions
- Owned C strings
- C calls Rust
- UTF-16 for Windows