How stclib/stc works
Project type and purpose
• STC is a C99 library providing generic, typesafe, high-performance containers and algorithms (a “header-only” + mixed static/shared library).
• Users include templated headers for containers and link the small libstc for non-templated modules (cstr, cregex, cspan, random, etc.).
• The repo also contains docs, examples, tests, build scripts (Meson/Ninja, Makefile), and CI workflows.
File-structure overview
• Top level: meson.build, Makefile, .github/workflows/meson.yml
• /stc: public headers (containers, algorithms, common macros)
• src: .c implementations for non-templated modules + scripts (singleheader.py)
• docs: API docs (one .md per module), images
• examples: demonstration code organized by feature
• tests: unit tests driven by Meson and custom run.sh
High-level components
A. Build System
• Meson + Ninja (meson.build, meson_options.txt)
• Python scripts (singleheader.py)
• Makefile (legacy build target)
B. Public API
• /stc/*.h (templated containers & algorithms)
• Generated single-header variants
C. Library Core
• src/*.c (cstr, cregex, cspan, random, fmt, stc_core)
• Linked into libstc.{a,so,dll}
D. Documentation
• docs/*.md + docs/pics
• algorithm and container API references
E. Examples & Tests
• examples/**
• tests/**
• Dependent on build outputs and headers
F. CI/CD
• .github/workflows/meson.yml (build, test, publish)
Relationships & data flow
• Developer (or CI) invokes Meson → generates Ninja build graph.
• Ninja calls:
• Compile src/*.c → libstc
• Copy/include headers → install/CPATH
• Run tests linking libstc + headers
• Build examples linking libstc + headers
• Run singleheader.py → produce standalone headers
• Consumers (example code / user projects) →
• Templated headers for container usage
• Link against libstc for non-templated functionality
• Docs are authored in Markdown and served or published separately.
Architectural patterns and principles
• Modular layering:
• Templated code (header-only, inline/static functions)
• Shared library modules (non-templated core)
• Meta-programming via C macros for generic containers (i_type, c_keyclass, etc.)
• Dual-mode compilation: header-only vs separate implementation
• CI integration with Meson to ensure tests/examples build across platforms