|
diff --git a/README.md b/README.md
|
| 1 |
**nonstd** is a single-header C library providing a collection of "non-standard" but highly useful utilities, data structures, and type definitions that are often missing from the C standard library. It aims to make C programming more ergonomic and productive without the overhead of large frameworks. |
1 |
**nonstd** is a single-header C library providing a collection of "non-standard" |
|
|
2 |
but highly useful utilities, data structures, and type definitions that are |
|
|
3 |
often missing from the C standard library. It aims to make C programming more |
|
|
4 |
ergonomic and productive without the overhead of large frameworks. It aims to be |
|
|
5 |
C99 compliant. |
|
|
6 |
|
|
|
7 |
> [!IMPORTANT] |
|
|
8 |
> There are much better more involved libraries out there. This library is |
|
|
9 |
> intended for ease of use first and foremost. It is not a replacement for |
|
|
10 |
> those libraries. |
| 2 |
|
11 |
|
| 3 |
## Features |
12 |
## Features |
| 4 |
|
13 |
|
| 5 |
- **Shorthand Types**: Concise integer types (`i8`, `u32`, `usize`, etc.) for better readability. |
14 |
- **Shorthand Types**: Concise integer types (`i8`, `u32`, `usize`, etc.) for better readability. |
| 6 |
- **Utility Macros**: Common helpers like `countof`, `MIN`, `MAX`, `CLAMP`, and `static_foreach`. |
15 |
- **Utility Macros**: Common helpers like `countof`, `MIN`, `MAX`, `CLAMP`, and `static_foreach`. |
| 7 |
- **String View (`stringv`)**: Efficient, non-owning, read-only string references to avoid unnecessary copies. |
16 |
- **String View (`stringv`)**: Non-owning, read-only string references to avoid unnecessary copies. |
| 8 |
- **String Builder (`stringb`)**: Growable, mutable string buffer for efficient string construction. |
17 |
- **String Builder (`stringb`)**: Growable, mutable string buffer for efficient string construction. |
| 9 |
- **Dynamic Array (`array`)**: Type-safe, generic growable arrays implemented via macros (similar to `std::vector` in C++). |
18 |
- **Dynamic Array (`array`)**: Generic growable arrays implemented via macros (similar to `std::vector` in C++). |
| 10 |
- **Slices (`slice`)**: Generic non-owning views into arrays. |
19 |
- **Slices (`slice`)**: Generic non-owning views into arrays. |
| 11 |
- **Memory Arena**: Simple and efficient block-based arena allocator for bulk memory management. |
20 |
- **Memory Arena**: Simple block-based arena allocator for bulk memory management. |
| 12 |
- **File I/O**: Helper functions to read and write entire files with a single call. |
21 |
- **File I/O**: Helper functions to read and write entire files with a single call. |
| 13 |
|
22 |
|
| 14 |
## Installation |
23 |
## Installation |
| ... |
| 16 |
`nonstd` is a single-header library. To use it: |
25 |
`nonstd` is a single-header library. To use it: |
| 17 |
|
26 |
|
| 18 |
1. Copy `nonstd.h` into your project's include directory. |
27 |
1. Copy `nonstd.h` into your project's include directory. |
| 19 |
2. In **one** C source file, define `NONSTD_IMPLEMENTATION` before including the header to create the implementation: |
28 |
2. In **one** C source file, define `NONSTD_IMPLEMENTATION` before including the |
|
|
29 |
header to create the implementation: |
| 20 |
|
30 |
|
| 21 |
```c |
31 |
```c |
| 22 |
#define NONSTD_IMPLEMENTATION |
32 |
#define NONSTD_IMPLEMENTATION |
| ... |
| 30 |
``` |
40 |
``` |
| 31 |
|
41 |
|
| 32 |
## Usage |
42 |
## Usage |
|
|
43 |
|
|
|
44 |
Check the `examples` directory for usage examples. But here are a few simple |
|
|
45 |
examples: |
| 33 |
|
46 |
|
| 34 |
### 1. Basic Types & Macros |
47 |
### 1. Basic Types & Macros |
| 35 |
|
48 |
|
| ... |
| 154 |
|
167 |
|
| 155 |
## Testing |
168 |
## Testing |
| 156 |
|
169 |
|
| 157 |
The project includes a comprehensive test suite using `minunit`. |
170 |
The project includes a test suite using `minunit`. |
| 158 |
|
171 |
|
| 159 |
To build and run the tests: |
172 |
To build and run the tests: |
| 160 |
|
173 |
|
| 161 |
```bash |
174 |
```bash |
| 162 |
make test |
175 |
make test |
| 163 |
``` |
176 |
``` |