Skip to content

rux-lang/C

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

C

C standard libary bindings for Rux.

Installation

You can install the package using Rux CLI

rux add C

Or add C to your Rux.toml:

[Dependencies]
C = "*"

Overview

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.

Usage

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;
}

License

MIT

About

Rux package: C standard library bindings

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks