Manual
Introduction
Section titled “Introduction”SIECS is a compact archetype ECS runtime for C17 with a typed C++20 interface.
The runtime focuses on table-based iteration, explicit component/resource access, relations, inheritance, scheduling and tooling-friendly reflection.
Design Goals
Section titled “Design Goals”1. Performance
Section titled “1. Performance”Hot paths should operate on contiguous table columns and cached table matches.
Performance work should include both iteration and structural mutation.
SIECS favors explicit storage/query models over hidden per-entity dynamic dispatch.
2. Portability
Section titled “2. Portability”The core runtime is C17.
The C++ wrapper is C++20 and uses the C runtime rather than requiring a separate implementation.
The standalone distribution is intended to be easy to compile into ordinary applications.
3. Reusability
Section titled “3. Reusability”Components, systems and modules should be reusable without forcing an application-wide class hierarchy.
Modules provide import boundaries. Resources provide world-level dependencies. Relations model graph edges.
4. Usability
Section titled “4. Usability”Typed C/C++ helpers cover common operations while id-based APIs remain available for tools and generic code.
The documentation should explain semantics and cost, not only list function names.
5. Extensibility
Section titled “5. Extensibility”The runtime exposes modules, custom relations, custom observer events, reflection metadata, REST tooling and add-on packages.
6. Small explicit runtime
Section titled “6. Small explicit runtime”SIECS intentionally does not implement every feature found in larger ECS frameworks.
The manual documents the current SIECS API. Textual query languages, universal pair ids, generic trait graphs and configurable cache kinds are not exposed.
API design
Section titled “API design”Naming conventions
Section titled “Naming conventions”C runtime operations use the ecs_ prefix.
Typed C++ functionality lives in the ecs namespace.
Typed macro declarations keep C and C++ ids aligned when a shared declaration is used.
Idempotence
Section titled “Idempotence”Operations that describe a desired state should avoid creating duplicate registrations or duplicate structural effects where possible.
Module import is idempotent per active world.
Removing a missing component/resource is a no-op.
Relating an entity to the target it already has does not create a meaningful retarget.
Error handling
Section titled “Error handling”Programming-contract violations are generally asserted in debug builds.
Examples include invalid query combinations, invalid relation storage use and unsafe registration during scheduler-parallel execution.
Application code should not treat assertions as recoverable user-input errors.
Memory ownership
Section titled “Memory ownership”Entity/component field pointers are borrowed from table storage.
Observer payloads are borrowed for the callback.
Scene buffers returned by save APIs have explicit ownership/free operations.
Names/reflection metadata follow their documented registration ownership rules.
When in doubt, keep stable ids/handles and reacquire pointers.
Macros
Section titled “Macros”The C API uses macros for typed declarations and compound-literal convenience.
Examples:
ECS_COMPONENT(...)ECS_TAG(...)ECS_RESOURCE(...)ECS_RELATION(...)ecs_query({...})ecs_system({...})ecs_observer({...})The underlying descriptor functions remain available for generic/runtime code.
Modules
Section titled “Modules”Modules group registrations and can toggle captured systems/observers.
Module import order does not replace scheduler dependency declarations.
Deferred operations
Section titled “Deferred operations”ecs_defer_begin() / ecs_defer_end() buffer ECS mutation.
Systems that iterate entities use deferred structural mutation by default.
The outermost defer end flushes commands.
Deferred operations are central to safe table iteration because structural changes can move rows and invalidate current field pointers.
World model
Section titled “World model”SIECS uses one active world.
This simplifies typed id storage and the public API but means applications should not assume multiple independent live worlds can be manipulated through the same global typed registrations simultaneously.
Tests should initialize/finalize cleanly and avoid leaking handles/ids between world lifetimes.
Registration timing
Section titled “Registration timing”Register components, relations, systems, observers and long-lived queries during initialization/module import.
Some registration operations are forbidden while scheduler-parallel work is active because they modify global indexes/plans.
Dynamic gameplay should normally create entities/data, not continuously redefine the ECS schema.
Stable handles versus unstable addresses
Section titled “Stable handles versus unstable addresses”The entity handle is designed to survive table migration while the entity is alive.
Component addresses are not.
This distinction is foundational:
store entity handle long-termreacquire component pointer short-termThe same applies to query iterator field arrays.
Debug versus release contracts
Section titled “Debug versus release contracts”Some component mutation metadata and assertions exist primarily in debug builds.
Do not design correctness around a debug-only field being present at runtime.
Use debug contracts to catch misuse and use normal ECS structure/access rules for release correctness.
C/C++ interoperability
Section titled “C/C++ interoperability”Shared macro declarations are intended to keep one component/resource/relation identity across language boundaries.
A C++ wrapper does not change storage layout owned by the C runtime.
When sharing a type between C and C++, keep instance data layout compatible and put C++-only methods behind the supported declaration helpers without adding hidden instance fields.
Error boundaries
Section titled “Error boundaries”SIECS APIs distinguish programmer-contract errors from ordinary absence.
Examples of ordinary absence:
ecs_lookup()returns0;try_getreturns null;try_resourcereturns null.
Examples of contract violations:
- using an invalid storage mode with a query term;
- registration at an unsafe scheduler time;
- invalid defer-scope balancing.
Use the nullable/query APIs when absence is expected instead of catching a debug assertion as control flow.

