Extern "C"
In Rust, extern "C" specifies the C calling convention for functions and foreign-function interfaces.
Refactoring to Rust
extern "C" is a Rust function annotation that gives a function the C ABI and makes it callable according to C conventions.
- How it is used
- Connects Rust functions to C handlers and callbacks across an FFI boundary.
- How deep it goes
- Explains calling conventions and annotation combinations, then demonstrates handlers and function-pointer types without detailing ABI internals.
- Examples
- Uses an NGINX request handler, a request-body callback, and a Rust-only request-body conversion helper.
- What you can do after
- Apply it to declare Rust functions callable from C and to type callbacks passed through C APIs.
Rust in Action: Systems programming concepts and techniques
extern "C" is Rust syntax that specifies C-compatible calling and linkage conventions for functions or foreign-function interfaces.
- How it is used
- Sets C calling conventions for a kernel entry point and declares externally provided LLVM functions.
- How deep it goes
- Explains the calling-convention purpose and shows both function and block syntax, without detailing argument layout.
- Examples
- Shows a kernel `_start` function and declarations for LLVM setjmp and longjmp intrinsics.
- What you can do after
- Apply it to a kernel entry point or external function declarations while distinguishing calling conventions from symbol names.
Read how Rust in Action: Systems programming concepts and techniques explains extern "C" →
Related concepts
- calling conventionuses · A calling convention is a set of platform-specific binary-interface rules governing how functions receive arguments, return values, preserve state, and manage calls.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

