2025-12-21 21:19:50 +01:00
2025-12-21 21:19:50 +01:00
2025-12-21 19:51:42 +01:00
2025-12-21 19:51:42 +01:00
2025-12-21 17:30:13 +01:00
2025-12-21 19:51:42 +01:00
2025-12-21 21:19:50 +01:00
2025-12-21 21:19:50 +01:00
2025-12-21 18:17:22 +01:00

libguf - typesafe C99 containers
--------------------------------------------------------------------------------

1. Intro
----------
"Look mom, no void pointers!"

This is a work in progress of my personal header only datastructure and 
algorithm utility library which (ab)uses the C pre-processor to achieve 
typesafety. 

There is no reason this exists apart from "this is kind of fun and silly",
you should just use C++ :)

It uses a similar approach of "include parametrisation" to achieve strongly 
typed data structures as https://github.com/ludocode/pottery (last-retrieved 
2025-12-21)

Look at "src/test/example.c" for an example. 


2. How to build
-----------------
Setup CMake with 
$ cmake -DCMAKE_BUILD_TYPE=Debug -S . -B build/debug

And build the example with
$ cmake --build build/debug/ --target libguf_example


3. Tests
----------
The tests in src/test are written in C++20, which made it easy to just use the 
STL types to check their behaviour against the custom libguf C types. 


4. What it includes
--------------------
- guf_dbuf.h:	a dynamic array (like std::vector)
- guf_dict.h: 	a hashtable (elements are stored contiguously, like python3's 
                compact dicts)
- guf_str.h: 	a string-buffer with short-string-optimisation (guf_str) and
                a string-view (guf_str_view) type
- guf_rand.h:   random number algorithms
- guf_sort.h:   sort algorithms
- guf_math.h:   math I guess?
- guf_linalg.h: linear algebra types and algorithms for computer graphics etc.
- ... and more


5. License
-----------
MIT (cf. LICENSE.txt).

--------------------------------------------------------------------------------
~fruit
Description
Strongly typed C99 containers etc.
Readme 502 KiB
Languages
C 66%
C++ 27.3%
Python 6.1%
CMake 0.6%