Running Reox Code
Learn how to compile and run .rx and .reox files.
File Extensions
Reox supports two file extensions that are completely equivalent:
.rxShort form - convenient for quick scripts
.reoxFull form - recommended for projects
Run Directly (Interpreter Mode)
For quick testing, run code directly with the interpreter:
# Run a .rx file
$ reoxc --run hello.rx
# Run a .reox file
$ reoxc --run app.reox
# Short form
$ reoxc -r script.rxCompile to C
Generate optimized C code for production:
# Compile to C code
$ reoxc main.rx -o main.c
# Then compile with GCC/Clang
$ gcc main.c -o myapp -lm
$ ./myappCompile to Executable
Create a standalone executable with optimization:
# Full optimization pipeline
$ reoxc app.reox --emit exe -o myapp -O3 --lto
# Options:
# --emit exe Generate executable
# -O3 Maximum optimization
# --lto Link-time optimization
# --strip Remove debug symbolsImports and Modules
Split your code into multiple files using import:
// math_utils.rx
fn square(x: int) -> int {
return x * x;
}
fn cube(x: int) -> int {
return x * x * x;
}// main.rx
import math_utils;
fn main() {
let result = square(5);
print(result); // 25
}Entry Point
For executable programs, define a main function:
// A complete Reox program
fn greet(name: string) {
print("Hello, " + name + "!");
}
fn main() {
greet("NeolyxOS");
}Best Practices
- ✓Use
.reoxfor main application files - ✓Use
.rxfor utility modules and scripts - ✓Keep one
main()function per executable - ✓Use
-O3 --ltofor production builds - ✓Test with
--runbefore compiling