Error codes

E0036: extern in a package without the ffi effect

In a terminal: auk explain E0036 prints this page.

On this page

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#

toml
[package]
name = "app"
version = "0.1.0"
effects = []
auk
extern fn c_abs(n: int): int = "int abs(int)"

fn main() uses ffi { print(c_abs(-3)) }

Fixed#

toml
[package]
name = "app"
version = "0.1.0"
effects = ["ffi"]

Common causes#

  • A new C binding in a package: add "ffi" to effects under [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.

Stuck on a word? Try the glossary. Got a compiler error? Look up its code. Improve this page