https://github.com/christophercrouzet/zero
Collection of single-file libraries for C/C++.
https://github.com/christophercrouzet/zero
c header-only library
Last synced: about 1 month ago
JSON representation
Collection of single-file libraries for C/C++.
- Host: GitHub
- URL: https://github.com/christophercrouzet/zero
- Owner: christophercrouzet
- License: mit
- Created: 2018-01-20T08:50:29.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-12-09T20:50:15.000Z (over 2 years ago)
- Last Synced: 2025-05-06T23:55:55.323Z (about 2 months ago)
- Topics: c, header-only, library
- Language: C
- Homepage:
- Size: 122 KB
- Stars: 47
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: changelogs/allocator.md
- License: LICENSE
Awesome Lists containing this project
README
Zero
====Zero is a bunch of single-file libraries for C/C++.
It is written in C89 at the exception of a couple of features borrowed from C99,
namely fixed-width integer types and variadic macros.## Features
* mostly C89-compliant
* headers don't include anything by default [1]
* implementations are included upon defining the `ZR_DEFINE_IMPLEMENTATION`
macro
* each library is a standalone single file to ease integration into projects
* simple1. The only exception being `` for headers defining functions with a
`va_list` object as parameter.## Libraries
| library | description | latest version | changelog |
|---------|-------------|----------------|-----------|
**[allocator.h](include/zero/allocator.h)** | Aligned and non-aligned wrappers of malloc/realloc/free | 0.2.0 | [changelog](changelogs/allocator.md)
**[dynamicarray.h](include/zero/dynamicarray.h)** | Contiguous array that can grow and shrink | 0.1.0 | [changelog](changelogs/dynamicarray.md)
**[logger.h](include/zero/logger.h)** | Simple logger with different log levels and colouring | 0.2.0 | [changelog](changelogs/logger.md)
**[timer.h](include/zero/timer.h)** | High-resolution real time clock and CPU (user/system) clocks | 0.2.0 | [changelog](changelogs/timer.md)## FAQ
### Why defining custom fixed-width integer types and even `size_t`?
Because most projects target common platforms (Windows, Linux, macOS), thus
using either the ILP32, LP64, or LLP64 data models, which all guarantee the
`char` type to be 8 bits, `short` to be 16 bits, `int` to be 32 bits, and
`long long` to be 64 bits. If such types can be accurately defined in a few
lines for most of the projects, then why including a standard header that
resolves to _thousands_ of lines of code with its dependencies? For the exotic
platforms, the macro `ZR_USE_STD_FIXED_TYPES` can be defined, or each type can
be overridden individually.The same applies to redefining `size_t`—on almost all platforms the size of
`size_t` equals the targeted architecture, that is either 32 or 64 bits. Here
again, if that's not enough then it's still possible to define
the macro `ZR_USE_STD_BASIC_TYPES`.Note that these custom types are only used for the public interface defined in
the headers, to avoid cluttering project headers including them. But the
implementation sections make free use of standard headers as needed
(including standard fixed-width integer types and `size_t`).