Skip to content

Pagghiu/SaneCppLibraries

Repository files navigation

Windows Linux+macOS Coverage

Sane C++ Libraries

YouTube X Discord GitHub Repo stars

Sane C++ Libraries is a set of C++ platform abstraction libraries for macOS, Windows and Linux.

Sane Cpp

Principles:

βœ… Fast compile times
βœ… Bloat free
βœ… Simple and readable code
βœ… Easy to integrate
⛔️ No C++ Standard Library / Exceptions / RTTI
⛔️ No third party build dependencies (prefer OS API)

Visit the documentation website for more information.

Take a look also at DeepWiki/SaneCppLibraries for an AI-guided walkthrough of the project!

Libraries

Each library:

  • Depends on the smallest possible subset of the others libraries (see Dependencies).
  • Has minimal headers, preferring to keep as much code as possible code in the implementation files.
  • Is available as a Single File Library amalgamated locally / offline or directly in the browser!
Library Description LOC
Algorithms πŸŸ₯ Placeholder library where templated algorithms will be placed 95
Async 🟨 Async I/O (files, sockets, timers, processes, fs events, threads) 5673
Async Streams πŸŸ₯ Concurrently read, write and transform byte streams 1975
Build 🟨 Minimal build system where builds are described in C++ 4159
Containers 🟨 Generic containers (SC::Vector, SC::SmallVector, SC::Array etc.) 779
File 🟩 Synchronous Disk File I/O 692
File System 🟩 File System operations (like copy / delete) for files / directories 1315
File System Iterator 🟩 Enumerates files and directories inside a given path 428
File System Watcher 🟩 Notifications {add, remove, rename, modified} for files / directories 1295
File System Watcher Async 🟩 Async backend for FileSystemWatcher 106
Foundation 🟩 Primitive types, asserts, compiler macros, Function, Span, Result 1173
Hashing 🟩 Compute MD5, SHA1 or SHA256 hashes for a stream of bytes 353
Http πŸŸ₯ HTTP parser, client and server 1260
Memory 🟩 Custom allocators, Virtual Memory, Buffer, Segment 1219
Plugin 🟨 Minimal dependency based plugin system with hot-reload 1426
Process 🟩 Create child processes and redirect their input / output 1294
Reflection 🟩 Describe C++ types at compile time for serialization 684
Serialization Binary 🟨 Serialize to and from a binary format using Reflection 572
Serialization Text 🟨 Serialize to / from text formats (JSON) using Reflection 645
Socket 🟨 Synchronous socket networking and DNS lookup 855
Strings 🟩 String formatting / conversion / manipulation (UTF8 / UTF16) 3362
Testing 🟨 Simple testing framework used by all of the other libraries 331
Threading πŸŸ₯ Atomic, thread, thread pool, mutex, condition variable 876
Time 🟨 Time handling (relative, absolute, high resolution) 346

Each library is color-coded to signal its status:
πŸŸ₯ Draft (incomplete, WIP, works on basic case)
🟨 MVP (minimum set of features have been implemented)
🟩 Usable (a reasonable set of useful features has been implemented)
🟦 Complete (all planned features have been implemented)

C Bindings

Some Libraries have C bindings

Binding Description
sc_hashing Bindings for the Hashing Library

Building

Libraries can be used as is, adding a single file to your project and without needing any build system.
See Building (user) to just use the library

Shortly:

  • Add SC.cpp to your build system of choice
  • Define SC_COMPILER_ENABLE_STD_CPP=1 if you plan to use the Standard C++ library
  • Include any public header (Libraries/[Library]/*.h)

Windows

  • If using MSVC required libraries are already implicitly linked through #pragma comment(lib, ...)

macOS / iOS

  • Link CoreFoundation.framework
  • Link CoreServices.framework

Linux

  • Link libdl (-ldl)
  • Link libpthread (-lpthread)

Examples

SCExample showcases integration of Sane C++ Libraries together with Dear ImGui and sokol libraries (see Examples page).

macOS

SCExample_04.mp4

iOS

SCExampleIOS_01.mp4

Tests

Tests are built with the self-hosted SC::Build project generator, describing the builds in C++.
Check Building (contributor) to run the tests.

Getting in touch

Alternatively I am also reading the following discords too:

Contributing

Please take some time to read the Principles and Coding Style.

After that you can read the CONTRIBUTING.md guide.

License

Sane C++ Libraries are licensed under the MIT License, see LICENSE.txt for more information.

Videos

On this YouTube Channel there are some videos showing bits of the development process.

Blog posts

On Sane Coding Blog there is a series of posts about this project.

Relevant yearly posts: