Avoid compiler warnings on 64-bit native Windows. Reported by Wilfredo Velázquez-Rodríguez at <https://savannah.gnu.org/bugs/?68178>. * lib/genaliases.c (emit_encoding): Emit a cast to size_t, not 'long'. * lib/genaliases2.c (emit_encoding): Likewise. * lib/iconv.c (sysdep_aliases): Cast to size_t, not 'long'.
diff --git a/ChangeLog b/ChangeLog index 451374e..f5a804a 100644 --- a/ChangeLog +++ b/ChangeLog
@@ -1,5 +1,14 @@ 2026-03-26 Bruno Haible <bruno@clisp.org> + Avoid compiler warnings on 64-bit native Windows. + Reported by Wilfredo Velázquez-Rodríguez at + <https://savannah.gnu.org/bugs/?68178>. + * lib/genaliases.c (emit_encoding): Emit a cast to size_t, not 'long'. + * lib/genaliases2.c (emit_encoding): Likewise. + * lib/iconv.c (sysdep_aliases): Cast to size_t, not 'long'. + +2026-03-26 Bruno Haible <bruno@clisp.org> + Switch to autoconf 2.73. * autogen.sh: Update comment.
diff --git a/lib/genaliases.c b/lib/genaliases.c index 8260681..be5c627 100644 --- a/lib/genaliases.c +++ b/lib/genaliases.c
@@ -1,4 +1,4 @@ -/* Copyright (C) 1999-2001, 2003, 2005, 2008, 2012, 2017, 2023 Free Software Foundation, Inc. +/* Copyright (C) 1999-2026 Free Software Foundation, Inc. This file is part of the GNU LIBICONV Library. The GNU LIBICONV Library is free software; you can redistribute it @@ -60,7 +60,11 @@ putc(c, out2); } } - fprintf(out2,"\")' tmp.h | sed -e 's|^.*\\(stringpool_str[0-9]*\\).*$| (int)(long)\\&((struct stringpool_t *)0)->\\1,|'\n"); + /* Use a cast to 'size_t', as an approximation to 'uintptr_t'. On most + platforms, the types 'long' and 'unsigned long' do work as well, but on + 64-bit native Windows platforms, they don't have the same size as pointers + and therefore generate warnings. */ + fprintf(out2,"\")' tmp.h | sed -e 's|^.*\\(stringpool_str[0-9]*\\).*$| (int)(size_t)\\&((struct stringpool_t *)0)->\\1,|'\n"); for (; n > 0; names++, n--) emit_alias(out1, *names, c_name); }
diff --git a/lib/genaliases2.c b/lib/genaliases2.c index 4b7942e..554d197 100644 --- a/lib/genaliases2.c +++ b/lib/genaliases2.c
@@ -43,7 +43,11 @@ static void emit_encoding (FILE* out1, FILE* out2, const char* tag, const char* const* names, size_t n, const char* c_name) { - fprintf(out2," (int)(long)&((struct stringpool2_t *)0)->stringpool_%s_%u,\n",tag,counter); + /* Use a cast to 'size_t', as an approximation to 'uintptr_t'. On most + platforms, the types 'long' and 'unsigned long' do work as well, but on + 64-bit native Windows platforms, they don't have the same size as pointers + and therefore generate warnings. */ + fprintf(out2," (int)(size_t)&((struct stringpool2_t *)0)->stringpool_%s_%u,\n",tag,counter); for (; n > 0; names++, n--) emit_alias(out1, tag, *names, c_name); }
diff --git a/lib/iconv.c b/lib/iconv.c index ec704cf..0767ca6 100644 --- a/lib/iconv.c +++ b/lib/iconv.c
@@ -190,7 +190,7 @@ }; #define stringpool2 ((const char *) &stringpool2_contents) static const struct alias sysdep_aliases[] = { -#define S(tag,name,encoding_index) { (int)(long)&((struct stringpool2_t *)0)->stringpool_##tag, encoding_index }, +#define S(tag,name,encoding_index) { (int)(size_t)&((struct stringpool2_t *)0)->stringpool_##tag, encoding_index }, #include "aliases2.h" #undef S };