Skip to content

Welcome to SML-Lib

A general purpose C library for not dealing with syntactic sugar and my personal c library too...

What can you do with this library?

Non-obfuscated Source Files

What you see is what you get. There is nothing separating you from the library.

This Library is your library

SML-Lib is licensed under BSD-3 clause meaning that you can redistribute this library with or without modification.

Platform and compiler independent math

Doing math is suprisingly hard and when I mean hard I really mean HARD it includes platform/compiler and chip specific things like __sin(x) or any other compiler specific math macro/function that might optimize your code on one platform but fail miserably on another*.

Headless and Full module integration

To bring the best memory efficiency for compiled programs this library is designed to be as interoperable with itself even when some of its necessary librarys are missing. This leads to variable behavior meaning that if you if you include one library but not the other your libary will work as expected but may change behavior when paired with another library.


An example of what this library can do

#include <stdio.h>
#include "modules/errors_and_logging.h"
#include "modules/common_bindings.h"
#include "modules/math.h"

int main(void) {
    printf("hello you!\n");
    printf("this is a file where you can try sml_lib without copying it :D\n");

    sml_error_config err_conf = init_sml_error(
            "SML_SANDBOX",
            false,
            NULL
    );

    // math.h does not rely on any preexisting math library. Let's it's check accuracy!
    printf("%f", LOGARITHM_ACC);

    // since we know that sin^2 + cos^2 = 1
    for (sml_size_t degree = 0; degree < 90; degree++) {
        printf("sin = %f, cos = %f, Accuracy = %f\n", sml_sin(degree), sml_cos(degree),
               sml_float_abs((sml_pow(sml_sin(degree), 2) + sml_pow(sml_cos(degree), 2))));
    }
    // note that using --ffast-math will change the output.
    // this is not because of any fancy tricks. This is just a pure math/skill issue.
    sml_throw_error(&err_conf, ERROR_OK, LOG_SEVERITY_INFO, "DONE!, %s", "With Style");

    return 0;
}