About the project
Several “single file” (i.e. the "" because in some cases there are two identically named files, namely one .h and one .c(pp)) libraries, some written in C linkeable C++ (i.e. not requiring linking to the C++ standard library binary), others written in C and one in Makefile. All libraries work on both windows and linux.
- tcp-mini (C++ TCP library for running one server to which client(s) can connect, non blocking)
- arguments-mini (C++ library for parsing
argvusing a format I personally use often)
- tint-mini (C library for converting between different tint representations)
- test-mini (C library that wraps main, malloc and free to detect memory leaks and also provide macros for running unit tests)
- array-mini (C library for array operations on pointers using elements of any size)
- check-mini (C library for validating variables by calling a validation function that can be derived from the variable’s type, the variable’s name or specified explicitly)
- makefile-mini (makefile library for generating targets I use in all *-mini projects)
- sharedlibrary-mini (library for compile time linking and runtime linking of sharedlibraries (.dll for windows and .so for linux))
- clock-mini (library for atleast microsecond precise time representation and converting between different time units)
- lcg-mini (library for generating psuedorandom numbers from a seed and a variable)
The first library I made was tcp-mini. I had never done socket programming before and nor linux programming (well a bit during my bachelor during a course, but the course supplied the linux things and focussed on opengl things), tcp-mini was my first introduction to both of these.
As I learned and sought answers to questions I added more features, some of which became later libraries (array-mini, check-mini, test-mini and makefile-mini all were first experiments in other *-mini projects but then became clear enough to turn into libraries).
At first I used Eclipse. Later I switched to Makefiles and make and platform specific scripts (.bat for windows and no extension but
#! /bin/sh at the top for linux) to retrieve the platform specific Makefile from a corresponding branch (using git-archive). I had never written a Makefile before and never used make, this was my first introduction to Makefiles and make.
These first and platform-specific Makefiles I wrote were entirely duplicated. Currently most still are entirely duplicated, as makefile-mini is a W.I.P., but they’re no longer platform specific.
The discontinuing of tcp-test-match and renaming of tcp-test-scout to tcp-mini-test merged both tests into one (using localhost and the test executable both creating the socket and connecting to it). This also introduced test macros (see link tooltip) that later became a feature of test-mini.
Later memory leak detection by wrapping malloc and free was added. This feature and the test macros together became the foundation for test-mini.
After these two features I switched from Eclipse to make. Using make required switching to a different folder/CLI window to run make there. I added a target
make andrun to compile and run tests with one command. At first this was fine, but as more projects were started this became confusing. I added a new target
make release in arguments-mini which executed a single executable (
test.exe for windows or
test for linux). Because of work on other libraries, and tcp-mini being quite usable, tcp-mini-test hasn’t been replaced yet, arguments-mini-test (which is now archived) has been replaced by a test in arguments-mini.
For lcg-mini I created a different type of test, namely a command line program that can generate individual psuedorandom numbers as well as generate .jpg files to see whether any repetition is visible looking at the image.
Versioning and releasing
For tcp-mini and for arguments-mini I made several releases. I created matching releases for arguments-mini-test too when that was still in a separate repository. I also made releases for tint-mini and for lcg-mini. Some projects (array-mini, check-mini, clock-mini, sharedlibrary-mini, test-mini and makefile-mini) currently have no releases, which I think is mostly due to the repetition of Makefiles that makefile-mini (which is currently W.I.P.) aims to solve.
All C/C++ *-mini libraries have a macro variable
#define *_MINI_VERSION (e.g. for tcp-mini
Headerguards use a macro
#define *_MINI_H named after the file the guard is in (e.g.
#define TCP_MINI_H for
tcp_mini.h). Typenames except enum, variablenames and functionnames are prefixed with
tm_ for tcp-mini). Macros are prefixed with
CM_ for check-mini). Enums are prefixed with
ECM for check-mini).
Though there are *-mini libraries that have the same function prefix (
am_ for both arguments-mini and array-mini,
tm_ for tcp-mini, tint-mini and test-mini), this is possible as long as each library contains different functions. There is a function
void *m_set_on_print(void(*a)(char*, FILE*)); in several *-mini libraries, but thusfar this works as there are different types of libraries..
- libraries intended to be fast thus don’t require printing functionality (e.g. array-mini and tint-mini)
- libaries intended to be reliable thus requiring printing functionality (e.g. arguments-mini and tcp-mini)
- libraries that contain an entry point and thus can print directly to stdout (e.g. test-mini which contains
All three types of library can be linked together, but there can only be one library of the 2nd type per letter (because of
*m_set_on_print) and only one library of the 3rd type (as there can only be one entry point). There can be any number of libraries of the 1st type, of which clock-mini and check-mini are an example.