Extern Declarations

The extern keyword declares functions that are defined outside Rux — typically in C / C++ libraries.

extern func malloc(size: uint) -> *opaque;
extern func free(ptr: *opaque);

Multiple declarations from the same library can be grouped in one extern block.

extern {
    func malloc(size: uint) -> *opaque;
    func realloc(ptr: *opaque, size: uint) -> *opaque;
    func free(ptr: *opaque);
}

Foreign functions exchange data through pointers: *opaque for handles, *T for read-only buffers, and *var T for buffers the callee may write to.

See Also