Hello world

This is the smallest Mox program that prints something. Make sure you did the setup first.

The program

Save this as hello.mox:

import "std.mox";

#linkc fn main(): i32 {
    println("hello {}!", .{ "world" });
    return 0;
}

Line by line:

Build and run

Pass the file to the compiler:

mox ./hello.mox

The compiler makes hello.mox.obj, then calls clang to link it into hello.mox.exe. Run it:

./hello.mox.exe

It prints hello world!.

To choose the output name and turn on optimizations:

mox ./hello.mox -O3 -o=./hello

Comments

// one line comment

/* comment
   on many lines */

Next: Compiler options.