From 390974b8a9d5e513d48d794818dbe180e0f80b16 Mon Sep 17 00:00:00 2001 From: Giulio Benetti Date: Fri, 28 Nov 2025 10:57:41 +0100 Subject: [PATCH] src/stdlib/SDL_iconv.c: fix types mismatch When building sdl this error shows up: ./src/stdlib/SDL_iconv.c: In function 'SDL_iconv': ./src/stdlib/SDL_iconv.c:50:29: error: passing argument 2 of 'iconv' from incompatible pointer type [-Wincompatible-pointer-types] 50 | retCode = iconv(cd, inbuf, inbytesleft, outbuf, outbytesleft); | ^~~~~ | | | const char ** Let's pick only this code from upstream commit[1] and left the rest untouched. Upstream: [1] [1]: https://github.com/libsdl-org/SDL-1.2/commit/8a8135d91f9361448521765c9da00401fab866a1 Signed-off-by: Giulio Benetti --- src/stdlib/SDL_iconv.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/stdlib/SDL_iconv.c b/src/stdlib/SDL_iconv.c index fa56a99e..369f6881 100644 --- a/src/stdlib/SDL_iconv.c +++ b/src/stdlib/SDL_iconv.c @@ -43,12 +43,10 @@ size_t SDL_iconv(SDL_iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft) { - size_t retCode; -#ifdef ICONV_INBUF_NONCONST - retCode = iconv(cd, (char **)inbuf, inbytesleft, outbuf, outbytesleft); -#else - retCode = iconv(cd, inbuf, inbytesleft, outbuf, outbytesleft); -#endif + /* iconv's second parameter may or may not be `const char const *` depending on the + C runtime's whims. Casting to void * seems to make everyone happy, though. */ + const size_t retCode = iconv((iconv_t) ((uintptr_t) cd), (void *)inbuf, inbytesleft, outbuf, outbytesleft); + if ( retCode == (size_t)-1 ) { switch(errno) { case E2BIG: -- 2.47.3