An open API service indexing awesome lists of open source software.

https://github.com/grauho/simpleheaderlibraries

A collection of small but useful header only C libraries that I've built up over time.
https://github.com/grauho/simpleheaderlibraries

ansi bitfields c89 c90 configuration-files endianness getopt getopt-long header-only header-only-library stdint thread-pool thread-pool-implementations vector-implementation

Last synced: 7 months ago
JSON representation

A collection of small but useful header only C libraries that I've built up over time.

Awesome Lists containing this project

README

          

.\" -*- mode: troff; coding: utf-8 -*-
.TH "" "7" ""
.SH Small Header Only Libraries
.LP
This repository contains several small header only libraries that contain
functions that are useful but missing from the C standard library with an aim
towards being portable across a wide range of potential C platforms. All of
these header libraries adhere to the ANSI C90 standard and where possible
constrain themselves to the \(oqfreestanding C\(cq subset of the standard library.
.PP
These libraries came about as a result of the specific needs of the author and
as such are not as robust as other larger libraries offering similar solutions.
If more functionality is desired one is advised to either expand these headers
oneself or seek out those aforementioned alternatives.
.SH Synopsis
.SS
port* files
.LP
These files often only require the user to include them in a single C
translation unit much like any other C header.
.PP
eg:
#include \(lqportopt.h\(rq
.SS
macro* files
.LP
These files contain macros that expand into a dynamically generated API with a
user defined namespace. The exact nature of this expansion is unique to the
file and as such have their own manual pages in their respective directories.
In general however one usually will need to include the respective header file
and then define a macro describing the desired namespace and other pertinent
information.
.LP
.EX
#include \(dqmacroThreadPool.h\(dq

#define MACRO_THREAD_POOL_COMPLETE(myPool, struct jobArgs, workerFunction);
.EE
.PP
Currently both macro dynamic headers have the option to define the resulting
function prototype, their definitions, or both depending on the macro invoked.
Please refer to the specific manual page for these files for more information.
.SH Summary
.SS
portegg.h
.LP
A library for detecting host Endian-ness and converting between big and little
Endian formats.
.SS
portopt.h
.LP
A library that provides both a simple and more verbose command line argument
parsing framework. Freestanding compatible if logging is disabled.
.SS
portcfg.h
.LP
A library for parsing basic configuration files. Not freestanding as it
requires I/O functions from stdio.
.SS
portint.h
.LP
A library intended to be a stopgap replacement for the basic types in stdint.h.
This header attempts to ascertain variable bit widths from their respective
limits in limits.h. Note that this is only guaranteed for unsigned integers,
although in most cases the corresponding signed variable will match the
bit-width of the unsigned variant.
.SS
portbit.h
.LP
A library created to attempt to address the platform dependant nature of
bitfields in the C standard. The purpose of this library is to allow for the
creation of bitfields of arbitrary length and allow for the reading and writing
of variables of arbitrary length to said bitfields. Freestanding if an
alternative calloc function is provided.
.SS
macroThreadPool/macroThreadPool.h
.LP
A library to dynamically generate a thread pool that allows for the queuing of
a specified job. pthread.h or an applicable wrapper that provides the pthread
API is required. See the manual page in the dedicated directory for more
information.
.SS
macroVector/cevMacro.h
.LP
A library to dynamically generate a dynamic array, or vector in C++ parlance,
of a given data type. Can be made freestanding compatible if alternatives for
the allocation functions and memmove/memcpy are provided. See the manual
page in the dedicated directory for more information.
.SH Examples
.LP
A directory containing examples for each of the non-macro headers is included
with this repository. All of the examples can be compiled with simply:
.LP
.EX
\(gacc file.c\(ga
.EE
.PP
to produce the corresponding demo program. Each of the macro headers contains
an example program in its personal directory along with a Makefile for
compiling the demo program.
.SH License
.LP
All the files in this repository are provided under the terms of the BSD
4-Clause License. A copy of this license can be found in the body of each of
the header files and also in LICENSE.txt.
.SH Bugs
.LP
Please report any bugs along with pertinent environmental information to the
bugs section of this repository. Feature suggestions or requests are not bugs.
.SH Authors
.LP
.EX
Grauho
.EE
.SH Copyright
.LP
Copyright \(co Grauho 2025, All Rights Reserved