A personal, header-only C99 standard library, built module-by-module while learning C. Modeled loosely on the stb single-header library philosophy: drop a single header into any project, no build step, no external dependencies.
Written targeting portability across desktop platforms and (eventually) console SDKs, which is why C99 rather than C11 is the enforced standard throughout. See Design Decisions below.
| Header | Description | Status |
|---|---|---|
psion_string_view.h |
Non-owning, bounds-safe view into a byte sequence | ✅ Complete |
Since every module is header-only, just copy the .h file you need into
your project and #include it. No linking required.
#include "psion_string_view.h"
Psion_StringView sv = Psion_StringViewFromCStr("Hello, World!");
Psion_StringView world = Psion_StringViewSubstring(sv, 7, 6);
Psion_StringViewPrint(world); // World!- C99, not C11. Chosen for maximum compiler/platform compatibility. Raylib made the same call for the same reason.
- Explicit lengths, never null-termination. Every type and function
in this library takes explicit lengths rather than relying on
strlen-style null-terminator scanning, to avoid an entire class of out-of-bounds bugs. - Fail-silent over fail-loud for recoverable bounds errors. Functions
like
Psion_StringViewSubstringclamp out-of-range input rather than asserting/aborting. Callers that need to detect truncation must check the returned length against the requested length — this is documented explicitly in each function's doc comment. - Header naming: every file is prefixed
psion_and every public symbol is prefixedPsion_, since C has no namespaces and collision avoidance has to happen at the identifier level.
Each module has a corresponding test file under tests/, using a small
custom macro-based test harness (tests/test_harness.h). Run the full
suite with:
make testTested against both GCC and Clang. Override the compiler with:
make CC=clang testThis is a header-only library. There is nothing to build or install to use it. The Makefile exists solely to build and run the test suite.