Re: setlocale: Silence a -Wdiscarded-qualifiers warning on Windows.

Bruno Haible via Gnulib discussion list <[email protected]>
Newsgroups gmane.comp.lib.gnulib.bugs
Organization GNU
Message-ID <8698041.T7Z3S40VBb@nimes>
Oops, the localeconv change leads to a compilation error on mingw:

x86_64-w64-mingw32-gcc -Wno-error -Wno-error -g -O2   -o test-locale-h.exe test-locale-h.o libtests.a ../gllib/libgnu.a libtests.a ../gllib/libgnu.a libtests.a  -lbacktrace
depbase=`echo test-localeconv.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
x86_64-w64-mingw32-gcc -DHAVE_CONFIG_H -DEXEEXT=\".exe\" -DEXEEXT=\".exe\" -I. -I../../gltests -I..  -DGNULIB_STRICT_CHECKING=1 -DIN_GNULIB_TESTS=1 -I. -I../../gltests -I.. -I../../gltests/.. -I../gllib -I../../gltests/../gllib -Wall -DCONTINUE_AFTER_ASSERT -Wno-error -Wno-error -g -O2 -MT test-localeconv.o -MD -MP -MF $depbase.Tpo -c -o test-localeconv.o ../../gltests/test-localeconv.c &&\
mv -f $depbase.Tpo $depbase.Po
../../gltests/test-localeconv.c:24:30: error: #if with no expression
   24 | #if GNULIB_defined_localeconv
      |                              ^
../../gltests/test-localeconv.c:27:1: warning: initialization of 'struct rpl_lconv * (*)(void)' from incompatible pointer type 'const struct rpl_lconv * (*)(void)' [-Wincompatible-pointer-types]
   27 | SIGNATURE_CHECK (localeconv, struct lconv *, (void));
      | ^~~~~~~~~~~~~~~
make[4]: *** [Makefile:27716: test-localeconv.o] Error 1

This patch should fix it.


2026-06-15  Bruno Haible  <[email protected]>

	localeconv: Fix compilation error on mingw (regression 2026-06-08).
	* lib/locale.in.h (GNULIB_defined_localeconv): Define to 1, not empty.

diff --git a/lib/locale.in.h b/lib/locale.in.h
index cdc3aab14f..e20d4fa5ff 100644
--- a/lib/locale.in.h
+++ b/lib/locale.in.h
@@ -251,7 +251,7 @@ struct lconv
 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 #   undef localeconv
 #   define localeconv rpl_localeconv
-#   define GNULIB_defined_localeconv
+#   define GNULIB_defined_localeconv 1
 #  endif
 _GL_FUNCDECL_RPL (localeconv, const struct lconv *, (void), );
 _GL_CXXALIAS_RPL (localeconv, const struct lconv *, (void));
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.