C standard libary bindings for Rux.
You can install the package using Rux CLI
rux add COr add C to your Rux.toml:
[Dependencies]
C = "*"This package provides thin bindings to the C standard library, exposed under the C module. Each source file mirrors a C standard header:
| Source | C header | Description |
|---|---|---|
Math.rux |
<math.h> |
Trigonometric, exponential, and other math functions |
StdIo.rux |
<stdio.h> |
File and console input/output |
StdLib.rux |
<stdlib.h> |
Memory allocation, conversions, random numbers, process |
Time.rux |
<time.h> |
Calendar time, clocks, and time formatting |
The Time module also defines the time_t and clock_t type aliases and the tm and timespec structs.
Import the functions you need from the C module and call them directly:
import C::{ localtime, printf, strftime, time };
func Main() -> int {
var now = time(null);
let local = localtime(&now);
var buffer: char8[64];
strftime(buffer.data, 64, "%Y-%m-%d %H:%M:%S\0".data, local);
printf("The time is %s\n\0".data, buffer.data);
return 0;
}