Collection of C libraries from scratch
2026-06-28 14:43:48 -03:00
docs chore: rename AOCLIBS to AOC for short 2026-06-26 14:26:15 -03:00
include feat(da): da_reserve can return da->data 2026-06-28 14:43:48 -03:00
libs chore(pp, crown): define dynamic arrays using DYNAMIC_ARRAY() 2026-06-26 15:12:59 -03:00
src chore(fork): write_fd returns bool 2026-06-28 14:43:47 -03:00
vendor chore: rename AOCLIBS to AOC for short 2026-06-26 14:26:15 -03:00
.clang-format style: use tabs instead of spaces 2026-06-16 19:29:31 -03:00
.gitignore feat: add build file containing C flags 2026-06-17 09:04:22 -03:00
build chore(build): passing -lm for io.h 2026-06-28 14:43:48 -03:00
build++ chore(build): passing -lm for io.h 2026-06-28 14:43:48 -03:00
compile_flags.txt chore: rename AOCLIBS to AOC for short 2026-06-26 14:26:15 -03:00
CONVENTION.md chore: rename AOCLIBS to AOC for short 2026-06-26 14:26:15 -03:00
LICENSE relicensing: the library is now just MIT 2026-06-17 18:13:52 -03:00
merge.c chore(merge): minor formatting and use eprintf 2026-06-26 17:13:14 -03:00
README.md relicensing: the library is now just MIT 2026-06-17 18:13:52 -03:00
template.h fix(template): using DYNAMIC_ARRAY in pp requires to define da.h first 2026-06-26 15:15:09 -03:00

aoclibs

This project is in constant development, although I use this almost everywhere, breaking changes may occur at any moment. It may take a while for this to become stable.

I'm the main consumer of this library. As I refuse to write in many modern programming languages, I stick to simplicity of C. However, relying solely in libc and also as I was implementing a tiny standard library in every single project I do in C was becoming very common, I just decided to develop a more robust and feature rich standard library for myself to enjoy programming in C more.

The goal is to make writing programs in C more enjoyable, and decrease the amount of external third-party dependencies in the project. As of now, aoclibs does only depends on libc, the third-party libraries are vendored in vendor, and in a few places, it uses POSIX specific APIs.

Who is this library for?

aoclibs is supposed to be used in new projects, mainly by vendoring the generated aoclibs.h as of the single header stb-style.

This library is only tested in x86_64 and aarch64 Linux and x86_64 FreeBSD. If you work on Windows this library will certainly not work, not even with MinGW. It might work on MacOS (I can't test it), and I may add support to other operational systems (NetBSD, OpenBSD, Haiku, DragonflyBSD) at some point.

aoclibs can currently be compiled with C++ without extern "C".

How to use

# Generate a single header with all the libraries
cc @build && ./merge
# Generate with C++
c++ @build++ && ./merge

Explore

Base libraries

Library Description
base.h Handful aliases and macros
buddy.h Buddy allocator
calculus.h Math
colors.h Terminal colors
cstr.h C String operations and slices
da.h Heap/stack-based dynamic arrays
libc.h Most included libc libraries
file.h File operations
fork.h Fork high-level wrappers
fquery.h "Regex"-like based on functions
hmap.h Unordered hashmap
io.h Input/output simple functions
map.h Ordered map
pp.h Pointer Pool
printfc.h printf() with colors
rc.h String type powered by da.h
stack.h Stack allocator

Libraries

Library Description
crown.h Full-blown CLI suite
debug.h Simple signal handler
heap_trace.h Catch malloc/calloc/realloc leaks
ini.h INI parser
spinner.h Simple spinner without allocations
tunit.h Test Unit

Vendored

Library Description License
arena.h Linked-list arena MIT
rapidhash General purpose hash function MIT

AI Disclosure

For transparency, this project is assisted by AI chatbots. The implied definition of the word "assisted", includes consulting AI to review and find bugs exclusively in C code. The implied definition doesn't include generating code by AI to speedup development, nor commit without human revision.

License

This repository is licensed under the MIT License, allowing for extensive use, modification, copying, and distribution.