Utilities for C-based projects.
A collection of shared components which I use in many of my C-based projects.
A small and platform-independent argument parser for console applications.
A customized version of the CuTest unit test framework. Has separate license file.
Look to the source code and header to see what modifications I made.
A platform-independent and compiler-independent memory leak checker for C.
A file stream reader inspired by stream reading mechanism in Node.js.
Platform-independent (byte) serialization and deserialization routines for integers.
There is an option to build platform-dependent versions which can yield faster runtimes.
SHA-256 calculation routine. I have adapted the unit tests for CuTest.
A Small Object Allocator (SOA). This is actually my own C port of the small object allocator described in the excellent book "Modern C++ Design" by Andrei Alexandrescu (2001).
This repo is a submodule of the cogu/c-apx (top-level) project.
The unit test project assumes that the repos are cloned side by side into a common directory.
- adt
- cutil (this repo)
cd ~
mkdir repo && cd repo
git clone https://github.com/cogu/adt.git
git clone https://github.com/cogu/cutil.git
cd cutil
First clone this repo and its dependency repo(s) side by side into a common directory (see example above). Alternatively the repos can be submodules of a top-level repo (as seen in cogu/c-apx).
For Windows, use a "Native tools command prompt" from your Visual Studio installation. It comes with a cmake binary that by default chooses the appropriate compiler version.
Configure:
cmake -S . -B build -DUNIT_TEST=ON
Build:
cmake --build build --target cutil_unit
Run test cases:
cd build && ctest
Some options are inherited from cogu/adt and apply here as well.
CMake Option | Usage | Description |
---|---|---|
BYTE_ORDER | -DBYTE_ORDER=[AUTO|NONE|LITTLE|BIG] | Platform byte order |
If the platform byte order is known during compile time we can switch the native-compatible pack-routines into memcpy calls which can be much faster. By default, CMake tries to automatically detect the byte order (AUTO) but you can force this value (to LITTE or BIG) in case that doesn't work.
When BYTE_ORDER is NONE the pack routines compiles in a form that should work for any platform (safe but slow).