~ashn/autil

Public domain utilities for C99
Update clang-format brace wrapping for composite type definitions
Add AUTIL_MEMZERO
Run clang-format

clone

read-only
https://git.sr.ht/~ashn/autil
read/write
git@git.sr.ht:~ashn/autil

You can also use your local clone with git send-email.

#AUTIL - ASHN'S UTILITIES

Public domain headers containing functions and data structures for rapid application development in C99 (or later).

Library Description
autil.h General purpose utility functions and data structures
atest.h Dead simple unit testing library
aengn.h 2D game engine with pixel coordinates (SDL2 backend)

See individual header files for usage instructions.

#Building and Running Unit/Integration Tests

#POSIX c99

$ make test CFLAGS='$(C99_DBG)'  # Debug
$ make test                      # Release

#GCC or Clang

$ make test CC=clang CFLAGS='$(GNU_DBG)'              # Debug
$ make test CC=clang CFLAGS='$(GNU_DBG) $(SANITIZE)'  # Debug with Address
                                                      # Sanitizer (glibc only)
$ make test CC=clang CFLAGS='$(GNU_REL)'              # Release

#Building and Running Examples

#Dependencies

Applications built using aengn.h link against SDL2, SDL2_image, and SDL2_mixer for native builds and compile with Emscripten's emcc for web builds. SDL2 and its extension libraries are provided by most package managers, and can be installed on Debian-based distros with:

$ apt-get install libsdl2-dev
$ apt-get install libsdl2-image-dev
$ apt-get install libsdl2-mixer-dev

The Emscripten toolchain can be downloaded and activated with:

$ git clone https://github.com/emscripten-core/emsdk.git
$ cd emsdk/
$ ./emsdk install latest  # Download and install latest SDK (do this once)
$ ./emsdk activate latest # Make the latest SDK active (do this once)
$ source ./emsdk_env.sh   # Setup envrionment (source this every time)

NOTE: Currently aengn.h and aengn example programs are known to compile on Debian stable using CC=gcc or CC=clang, but fail to compile with CC=musl-gcc and CC=tcc.

#Building

$ make examples CFLAGS='$(C99_DBG)'  # Debug   (c99)
$ make examples                      # Release (c99)

$ make examples CC=clang CFLAGS='$(GNU_DBG)'  # Debug   (gcc/clang)
$ make examples CC=clang CFLAGS='$(GNU_REL)'  # Release (gcc/clang)

$ make examples-web CFLAGS='$(GNU_DBG)'  # Debug   (emscripten)
$ make examples-web CFLAGS='$(GNU_REL)'  # Release (emscripten)

#Running

To run an example with the name example-name:

$ (cd examples/ && ./example-name)

which will set the working directory to example/ for applications that load assets via relative paths.

#License

All content in this repository is licensed under the Zero-Clause BSD license.

See LICENSE for more information.