Platform-Specific Code
How platform code works
Tape abstracts platform differences through the runtime library. Each target has its own runtime (rt/win64/, rt/uusi/, rt/linux/) that implements standard library modules like io. User code imports these modules without knowing which platform implementation backs them.
tape
import io from "io"; // resolved to platform-specific runtime at link time
io.println("works everywhere");@link directive
Declares a native library dependency:
tape
@link("user32");
extern fn MessageBoxA(hwnd: *u8, text: *u8, caption: *u8, flags: u32) -> i32;On Windows, this links against user32.dll. On Uusi, it links the corresponding .sto.
Available targets
| Target | Description |
|---|---|
win64 | Windows x86-64 (PE64) |
uusi | Uusi kernel (ELF64) |
linux | Linux x86-64 (ELF64) |
macos | macOS x86-64 |
macos-arm64 | macOS ARM64 |
Conditional compilation
For code that must differ per platform within a single module, use if inside a @tape {} block:
tape
@tape {
if (TARGET == "win64") {
@emit fn get_ticks() -> u64 { return GetTickCount() as u64; }
} else {
@emit fn get_ticks() -> u64 { return sys.ticks(); }
}
}Planned
TARGET is not yet exposed to comptime evaluation.Link modules
For complex FFI boundaries, use a dedicated link module:
tape
@link("opengl32");
pub extern fn glClear(mask: u32);
pub extern fn glClearColor(r: f32, g: f32, b: f32, a: f32);
pub extern fn glViewport(x: i32, y: i32, w: i32, h: i32);Other modules import this to access the extern functions without repeating @link.
Last modified: