Skip to content

zipsegv.net

XSTD

Created 8/9/2025, 4:54:38 PM

XSTD is an "extended standard library" for C99. In other words, it implements many useful data structures and algorithms that most modern languages come with. It is currently in a very early stage, and may or may not be particularly efficient.

Most utilities in the library work how a typical C library does. However, for collections, it uses macros to generate the header and implementation for a specific type. This effectively replicates what templates would do in other languages, but is a little more scuffed. For example, to generate a sequence (i.e. resizable array similar to C++ std::vector or Java ArrayList), you would need the following code:

// file.h #include <xstd/container/sequence.h> // generate header XSTD_SEQUENCE_H(int_seq, int_seq_t, int) // file.c #include "file.h" // generate impl XSTD_SEQUENCE_C(int_seq, int_seq_t, int)

Currently, there's no easily-browseable documentation as the API is still heavily in flux. However, the source code is well documented enough that just looking through the headers should give one an idea of how to use the library. Although, it is recommended to clone the library and look at it in a code editor, since sourcehut's* syntax highlighting for preprocessor macros is not great.

⇒ The source code for XSTD is hosted at sourcehut here.

Footnotes

* Or more accurately, pygment's ↩︎


Groups: Software