Skip to content

thetek42/empower

Repository files navigation

Empower

Empower is a collection of header-only libraries for C that empower you to write applications faster and with more joy.

Modules

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

Requirements

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).

Usage

The process is the same as for all STB-style header-only libraries:

  1. Download the .h file for the libraries you need and place them somewhere in your project.
  2. Include the libraries in the files where you need them.
  3. In one .c file, you will have to provide the implementation for the functions. For instance, when using e_mem, you have to #define E_MEM_IMPL before the include.
  4. Have fun!

Testing

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 c99

The targets for the tests are defined in tooling/targets.py

Development

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.

Adding new modules

To add a new module, follow these steps:

  1. Add -DE_<MODULE>_IMPL to .clangd and .clang-tidy
  2. Create the module in empower/e_<MODULE>.h (copy misc/module_template.h)
  3. Create the tests in tests/test_<MODULE>.c (copy misc/test_template.c)
  4. Call the module’s test function in tests/tests.c
  5. Update REAMDE.md and SUPPORT.md

About

A collection of header-only libraries for C that empower you to write applications faster and with more joy. – ⚠️ MIRROR OF https://git.tjdev.de/thetek/empower ⚠️

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors