External declarations

extern fn describes a function supplied outside Moon. Use types that match the actual native declaration. The example checks a signature with a signed 32-bit argument and result; it does not load or call a library.

A declaration alone supplies neither an implementation nor a lifetime guarantee. Raw foreign calls require unsafe, and executable calls also require a native binding. The current moon run does not discover native libraries from source declarations. An incomplete-lifetime warning from moon check is not proof that an external call is safe.

extern fn native_double(value: i32) -> i32

fn main() {}
Run locally
moon check main.mn
Ctrl/⌘+Enter checks the current lesson.