Skip to main content

C

Library can be either be used as a STB↗ style single header library1 or as a linked library.

Tested compilers:

  • gcc >= 13.3.0
  • clang >= 18.1.3
  • MSVC >= 19.44.35219.0

Include in a project

Library can be also directly included as in cmake a project.
In an existing project either clone it

git clone https://github.com/Imn0/timber.git libs/timber

or add as a submodule

git submodule add https://github.com/Imn0/timber.git libs/timber

Example CMakeLists.txt to link with a static version

add_subdirectory(libs/timber)
target_link_libraries(${PROJECT_NAME} timber::static)

Single header

  1. download tmb.h file and place it in your source tree.

    wget https://raw.githubusercontent.com/Imn0/timber/refs/heads/master/include/tmb/tmb.h
  2. then use it as follows

    #define TMB_LOGGING_IMPLEMENTATION
    #include "tmb.h"

    int main(void) {
    LOG_ERROR("Cannot build river");
    }

#define TMB_LOGGING_IMPLEMENTATION is needed in only one .c file, generally your main.
In every other file just include the tmb.h

System install

  1. Clone the repository

    git clone https://github.com/Imn0/timber.git
    cd timber
  2. Setup cmake

    mkdir build
    cd build
    cmake ..

    to change the install prefix

    cmake .. -DCMAKE_INSTALL_PREFIX:PATH=/home/$USER/opt/
  3. Compile and install

    cmake --build . --target install

    then link as normal

Footnotes

  1. When used in single header mode it has a limited feature set.