Open rongcuid opened 1 year ago
Describe the bug When using stb_ds, incompatible pointer type warning appear (and becomes error because of Werror):
stb_ds
Werror
error: passing 'const char *' to parameter of type 'void *' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers] arrsetlen(extensions, count); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /opt/local/include/stb/stb_ds.h:407:21: note: expanded from macro 'arrsetlen' #define arrsetlen stbds_arrsetlen ^ /opt/local/include/stb/stb_ds.h:539:67: note: expanded from macro 'stbds_arrsetlen' #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) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /opt/local/include/stb/stb_ds.h:538:33: note: expanded from macro 'stbds_arrsetcap' #define stbds_arrsetcap(a,n) (stbds_arrgrow(a,0,n)) ^~~~~~~~~~~~~~~~~~~~ /opt/local/include/stb/stb_ds.h:561:62: note: expanded from macro 'stbds_arrgrow' #define stbds_arrgrow(a,b,c) ((a) = stbds_arrgrowf_wrapper((a), sizeof *(a), (b), (c))) ^~~ /opt/local/include/stb/stb_ds.h:494:36: note: passing argument to parameter 'a' here extern void * stbds_arrgrowf(void *a, size_t elemsize, size_t addlen, size_t min_cap);
I believe that the stbds_arrgrow macro should explicitly cast a into a void pointer, like this: (void *) (a).
stbds_arrgrow
a
(void *) (a)
To Reproduce Steps to reproduce the behavior:
const char *test = NULL; arrsetlen(test, 10);
Expected behavior Compiles without warning or error
Describe the bug When using
stb_ds
, incompatible pointer type warning appear (and becomes error because ofWerror
):I believe that the
stbds_arrgrow
macro should explicitly casta
into a void pointer, like this:(void *) (a)
.To Reproduce Steps to reproduce the behavior:
Expected behavior Compiles without warning or error