extern fn binds a C function (and extern type a C pointer type). Calling C is unchecked: a
crash in C can't be caught. So only a package (or project) whose raft.toml declares the ffi
effect may do it, and every caller of an extern fn then needs uses ffi too.
Wrong#
[package]
name = "app"
version = "0.1.0"
effects = []extern fn c_abs(n: int): int = "int abs(int)"
fn main() uses ffi { print(c_abs(-3)) }Fixed#
[package]
name = "app"
version = "0.1.0"
effects = ["ffi"]Common causes#
- A new C binding in a package: add "ffi" to
effectsunder [package] (a visible, reviewable change). - A standalone file: C bindings need a project; create a raft.toml.
- Calling the runtime directly: use the core library (
proc.run,env.get, ...) instead.