How to Use extern "C" Functions in Unsafe Rust

Call C functions in Rust by declaring them in an extern "C" block and invoking them within an unsafe block.

Use the extern "C" block to declare the C function signature, then wrap the call in an unsafe block to execute it.

extern "C" {
    fn c_function_name(arg: i32) -> i32;
}

unsafe {
    let result = c_function_name(42);
}

This tells the compiler to use the C calling convention and disables safety checks for the function call.