| description | common libc extensions as C99 single-header "libraries" |
| last change | Fri, 17 Jul 2026 19:52:00 +0000 (15:52 -0400) |
| URL | git://git.datadissipation.net/libcext.git |
| https://git.datadissipation.net/libcext.git | |
| content tags |
A collection of portable, strict C99, single-header implementations of common libc extensions.
All functions are implemented as macros expanding to an internal function reference, this allows to use the headers with no meta build system - it compiles even if the extensions are already present, see How to on disabling this behaviour.
Include the header in every file needed as usual:
#include "${function}.h"
In the file chosen for the function implementation:
#define LCE_${FUNCTION}_IMPLEMENTATION
#include "${function}.h>"
By default, the header won’t have any stdlib includes, change that with:
#define LCE_${FUNCTION}_INCLUDE_LIBC
Or disable function, type and variable override with:
#define HAVE_${FUNCTION}
includes vasprintf() and asprintf()
includes fgetln()
includes getopt(), getsubopt(),
getopt_long() and getopt_long_only()
getopt_long.h has additional macros related to argument
permuting, defining those enables it per function (GNU behaviour, can
still be disabled at runtime by setting
$POSIXLY_CORRECT):
#define LCE_GETOPT_PERMUTE_ARGS
#define LCE_GETOPT_LONG_PERMUTE_ARGS
#define LCE_GETOPT_LONG_ONLY_PERMUTE_ARGS
includes strdup() and strndup()
strndup() follows the latest standard, meaning that it
copies at most n chars, not n + 1. Also, no standard
specifies that strndup() should return less than n
if strlen(s) + 1 < n, but this implementation
does so.
includes strlcat() and strlcpy()
includes strtonum()
| 10 days ago | master | shortlog | log | tree |