Empower is a collection of header-only libraries for C that empower you to write applications faster and with more joy.
Empower contains the following modules:
| Category | Module | Description |
|---|---|---|
| Strings | e_cstr | String utility functions |
| e_sb | String builder | |
| e_sv | String view | |
| e_char | A ctype.h that doesn’t suck | |
| Data structures | e_da | Generic dynamic arrays |
| e_queue | Generic double-ended queue | |
| e_rbuf | Generic ringbuffer | |
| e_bitvec | Bit array | |
| Algorithms | e_base64 | Base64 encoding/decoding |
| e_bcd | Binary-coded decimals | |
| e_cobs | COBS encoding/decoding | |
| e_cobsr | COBS/R encoding/decoding | |
| File formats | e_ini | INI file parsing |
| Allocation | e_alloc | Memory allocation |
| e_arena | Arena allocator | |
| Memory manipulation | e_mem | Memory manipulation |
| e_endian | Endian conversion | |
| Utilities | e_debug | Debugging utilities |
| e_log | Logging | |
| e_macro | Macro helpers | |
| e_rand | Randomization | |
| Compatibility | e_compat | C standard / compiler compatibility |
| e_stdc | Uniform feature test macros | |
| Testing | e_test | Testing |
Check SUPPORT.md for detailed information about which C standards, compilers and platforms are supported.
TL;DR:
- C Standard Version: Most modules support C89, some require C99, but C11 and C23 unlock a few extra features.
- Compilers: GCC, Clang, TinyCC, MinGW GCC and MSVC are officially supported, others likely work as well.
- Platforms: Most modules are platform independent and work in freestanding environments. Platform-dependent modules work on POSIX (tested on Linux with glibc) and Windows (tested with Wine with both MinGW and MSVC).
The process is the same as for all STB-style header-only libraries:
- Download the
.hfile for the libraries you need and place them somewhere in your project. - Include the libraries in the files where you need them.
- In one
.cfile, you will have to provide the implementation for the functions. For instance, when usinge_mem, you have to#define E_MEM_IMPLbefore the include. - Have fun!
To execute the tests, you can use the tooling/tests.py script:
# execute tests for all targets and C standards
python3 tooling/tests.py
# execute tests for targets "native-gcc" and "native-clang" for all C standards
python3 tooling/tests.py native-gcc native-clang
# execute tests for all targets with C11
python3 tooling/tests.py c11
# execute tests for "mingw-x64" with C89 and C99
python3 tooling/tests.py mingw-x64 c89 c99The targets for the tests are defined in tooling/targets.py
The repository provides configuration files for clangd and clang-tidy. They expect you to be working on POSIX environments. For Windows, you will not get fancy code completion and errors.
For clang-tidy, the script tooling/clang-tidy.sh can be run. If you want to
contribute something, please run clang-tidy to ensure that you didn't mess up
somewhere.
To add a new module, follow these steps:
- Add
-DE_<MODULE>_IMPLto.clangdand.clang-tidy - Create the module in
empower/e_<MODULE>.h(copymisc/module_template.h) - Create the tests in
tests/test_<MODULE>.c(copymisc/test_template.c) - Call the module’s test function in
tests/tests.c - Update REAMDE.md and SUPPORT.md