From 47c65020e92ad582a1c711bc1f82af48fde0570a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Goudet=20Alvim?= Date: Mon, 23 Dec 2024 01:31:34 -0300 Subject: [PATCH] Prevent warning due to type-limits on `arrsetlen(arr, 0)` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As suggested by @nothings, cast array capacity and new capacity to `ptrdiff_t` in order to avoid 'always-falseĀ“ complaints that arise from `-Wextra`. --- stb_ds.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stb_ds.h b/stb_ds.h index e84c82d1d5..a209685290 100644 --- a/stb_ds.h +++ b/stb_ds.h @@ -536,7 +536,7 @@ extern void * stbds_shmode_func(size_t elemsize, int mode); #define stbds_temp_key(t) (*(char **) stbds_header(t)->hash_table) #define stbds_arrsetcap(a,n) (stbds_arrgrow(a,0,n)) -#define stbds_arrsetlen(a,n) ((stbds_arrcap(a) < (size_t) (n) ? stbds_arrsetcap((a),(size_t)(n)),0 : 0), (a) ? stbds_header(a)->length = (size_t) (n) : 0) +#define stbds_arrsetlen(a,n) (((ptrdiff_t) stbds_arrcap(a) < (ptrdiff_t) (n) ? stbds_arrsetcap((a),(size_t)(n)),0 : 0), (a) ? stbds_header(a)->length = (size_t) (n) : 0) #define stbds_arrcap(a) ((a) ? stbds_header(a)->capacity : 0) #define stbds_arrlen(a) ((a) ? (ptrdiff_t) stbds_header(a)->length : 0) #define stbds_arrlenu(a) ((a) ? stbds_header(a)->length : 0)