Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

psion_lib

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.

Modules

Header Description Status
psion_string_view.h Non-owning, bounds-safe view into a byte sequence ✅ Complete

Usage

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!

Design Decisions

  • 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_StringViewSubstring clamp 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 prefixed Psion_, since C has no namespaces and collision avoidance has to happen at the identifier level.

Testing

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 test

Tested against both GCC and Clang. Override the compiler with:

make CC=clang test

Building

This 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.

About

A personal, header-only C99 standard library

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages