Skip to content

jyatesdotdev/c-comprehensive-template

Repository files navigation

C Comprehensive Template

A production-ready C project template covering systems programming, high-performance computing, rendering pipelines, and simulation — with modern best practices (C17).

Quick Start

mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make -j$(nproc)
ctest --output-on-failure

Build Options

Option Default Description
BUILD_TESTS ON Build unit tests
BUILD_EXAMPLES ON Build example programs
BUILD_DOCS OFF Build Doxygen documentation
ENABLE_SANITIZERS OFF Enable AddressSanitizer + UBSan
ENABLE_RENDERING OFF Build rendering modules (requires OpenGL)

Project Structure

├── CMakeLists.txt          Root build configuration
├── AGENTS.md               Agent guide (conventions, build loop, module recipe)
├── cmake/Platform.cmake    Platform & SIMD detection
├── scripts/new_module.sh   Scaffold a new module (files + CMake targets)
├── include/                Public headers
│   ├── core/               Error handling, logging, monotonic time
│   ├── containers/         Vec, hash map, string builder, ring buffer
│   ├── memory/             Arena & pool allocators
│   ├── systems/            File I/O, process control, paths
│   ├── hpc/                SIMD, thread pool, parallel_for, queues
│   ├── math/               Vectors, matrices, quaternions, RNG, stats
│   ├── ml/                 Neural net layers, losses, optimizers, datasets
│   ├── networking/         TCP, UDP, Unix sockets, event loop
│   ├── rendering/          Software renderer, GL pipeline
│   └── simulation/         Physics, numerical methods
├── src/                    Implementation files
├── tests/                  Unit tests
├── examples/               Working demos
├── docs/                   Doxygen config
└── third_party/            Vendored dependencies

Modules

  • core: Unified error codes, leveled logging, monotonic time/stopwatch
  • containers: Growable array, string-keyed hash map, string builder/views, ring buffer, FNV-1a/CRC-32
  • memory: Arena (bump) allocator and fixed-size pool allocator
  • systems: Safe file I/O wrappers, process control, path utilities
  • hpc: SSE/AVX SIMD operations, pthreads thread pool, parallel_for, SPSC/MPMC queues
  • math: Vec2/3/4, Mat4 transforms, quaternions, dynamic MatX matrices, PCG32 RNG, statistics
  • ml: Dense layers with manual backprop, MSE/cross-entropy, SGD/Adam, CSV/shuffle/batch utilities
  • networking: TCP client/server, UDP datagrams, Unix domain sockets, poll event loop (POSIX)
  • simulation: Euler physics integration, Simpson's rule, bisection root finding
  • rendering: Software framebuffer renderer, OpenGL shader pipeline (optional)

Documentation

Document Description
AGENTS Condensed guide for AI coding agents (CLAUDE.md symlinks here)
ARCHITECTURE Project structure, module dependencies, CMake targets
TOOLCHAIN Required tools, install instructions, IDE setup
TUTORIAL New developer walkthrough — build, test, extend
EXTENDING Adding modules, tests, examples, and dependencies
BEST_PRACTICES Coding standards, error handling, memory safety
CLI CLI argument parsing, subcommands, output formatting
SECURITY_SCANNING Static analysis, sanitizers, CI security gates
OPTIMIZATION Profiling, compiler flags, performance patterns
CROSS_PLATFORM Portability guide — Linux, macOS, Windows
THIRD_PARTY Third-party library integration (SDL2, GLFW, cglm, stb)

About

Comprehensive C project template with CMake, testing, security scanning, CLI examples, and Docker support

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors