Xo is experimental. The source is now public on GitHub, or try Xo in your browser.
Menu · XO1518

Docs

XO1518: a C export breaks a rule

error · reported by the checker

A C export (decision 0574) is a top level pub fn, not generic, whose parameters are Int, Float, Bytes, Str or values held by an XoHandle (not Bool or a function type, no var, at most 8 integer words: a Bytes or Str takes 2, an error result 1), whose result is Int, Float, a value held by an XoHandle or none (not Bytes, Str, Bool or a function), with or without an error type, and whose C name is a C identifier outside the runtime’s xo_ names.

Example

pub fn (p: Point) norm() -> Float as c "point_norm" { p.x }

Fix

pub fn point_norm(x: Float, y: Float) -> Float as c "point_norm" { (x * x + y * y).sqrt() }

Run xo explain XO1518 for this text in a terminal, or see section 10.6 of the specification.