HANDMADE GAMEDEV

STDX - My Standard C Library

About two years ago I decided that I would use C instead of C++ for my personal projects. Life is too short to program C++ at work and in personal projects.

Because of that decision I quickly found myself reimplementing the same basic functionality over and over again: arenas, hash tables, filesystem utilities, string helpers, and similar infrastructure. Eventually I decided to stop rewriting these pieces in every project and instead implement them once in a reusable way. At the same time I gathered other bits of common code I had written over the years — some of it originally written in C++, later rewritten in C. The result became my own standard library called STDX .


What is STDX

STDX is a collection of small utility libraries for C that provide implementations of common data structures and system helpers. Each module solves a specific problem and can be used independently.

All modules are single-header libraries.
The implementation is enabled by defining a macro in exactly one translation unit:

#define X_IMPL_ARRAY
#include "stdx_array.h"

This allows the library to be dropped directly into a project without requiring a specific build system.


Design Philosophy

The STDX headers follow a very recognizable structure:

There are no compiler tricks, no heavy metaprogramming, and very little hidden behavior. The goal is predictable cost and straightforward correctness. The code should be readable from top to bottom and understandable without surprises.


Feature Overview

STDX ships as a set of modules inside src/, each focused, readable, and self-contained.

Core

Memory & Containers

Strings & Text Utilities

Platform & System Helpers

Diagnostics & Tooling


Tools

In addition to the libraries, the project also includes a small set of command-line tools built on top of STDX. They are small utilities that solve specific problems and are implemented using the same principles as the library itself: simple code, minimal dependencies, and predictable behavior.

Two examples are currently included in the repository.

bake

bake is a small utility that helps embed files into C source code.

It reads an input file and generates C code that contains the file's contents as static data. This makes it possible to compile resources such as shaders, configuration files, or other assets directly into a program without relying on external files at runtime. bake is also used to generate string intern tables.

String interning is a technique where identical strings are stored only once in memory and referenced through pointers or IDs. Instead of comparing strings character-by-character, the program can simply compare pointers or integer identifiers.

For example, instead of repeatedly allocating and comparing strings like:

 "open"
 "close"
 "open"
 "close"

the system stores each unique string only once:

  open  -> id 1
  close -> id 2

Every occurrence of "open" then references the same interned entry.

This has several advantages: faster comparisons (pointer or integer comparison instead of strcmp), reduced memory usage, stable identifiers for strings used as keys or symbols Using bake, these intern tables can be generated ahead of time and compiled directly into the program.

doxter

doxter is the documentation generator used for STDX itself.

It parses specially formatted comments inside the headers and produces the documentation available here . The tool was designed specifically for this project, with the goal of keeping the documentation process simple and tightly integrated with the code. Like the rest of the project, it avoids heavy dependencies and focuses on straightforward processing of the source files.