From d0f5be14558e2b0cc506654bd45bb6d81553c456 Mon Sep 17 00:00:00 2001 From: Mitja Felicijan Date: Fri, 23 Jan 2026 00:02:07 +0100 Subject: Update to readme and added UNREACHABLE and TODO macros --- README.md | 6 +++++- nonstd.h | 13 ++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a985e82..009af3f 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ ergonomic and productive. It aims to be C99 compliant. > [!IMPORTANT] > There are more involved libraries out there providing better granularity > and functionality. This library is intended for ease of use first and -> foremost. It is not a replacement for those libraries. +> foremost. It is not a replacement for those libraries. Use at your own risk. ## Features @@ -220,3 +220,7 @@ To build and run the tests: ```bash make test ``` + +## Acknowledgments + +- https://github.com/tsoding/nob.h \ No newline at end of file diff --git a/nonstd.h b/nonstd.h index f4f6292..3e39380 100644 --- a/nonstd.h +++ b/nonstd.h @@ -60,7 +60,18 @@ NONSTD_DEF void *safe_realloc(void *ptr, size_t item_size, size_t count); #define MAX(a, b) ((a) > (b) ? (a) : (b)) #define CLAMP(x, lo, hi) (MIN((hi), MAX((lo), (x)))) -#define UNUSED(x) (void)(x) +// From https://github.com/tsoding/nob.h/blob/e2c9a46f01d052ab740140e74453665dc3334832/nob.h#L205-L206. +#define UNUSED(value) (void)(value) +#define TODO(message) \ + do { \ + fprintf(stderr, "%s:%d: TODO: %s\n", __FILE__, __LINE__, message); \ + abort(); \ + } while (0) +#define UNREACHABLE(message) \ + do { \ + fprintf(stderr, "%s:%d: UNREACHABLE: %s\n", __FILE__, __LINE__, message); \ + abort(); \ + } while (0) #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L #define STATIC_ASSERT(expr, msg) _Static_assert((expr), msg) -- cgit v1.2.3