+2026-02-27 Bruno Haible <bruno@clisp.org>
+
+ wctype-h: Try to fix error regarding mbstate_t on very old mingw.
+ Reported by Eli Zaretskii, see
+ <https://lists.gnu.org/archive/html/bug-gnulib/2026-01/msg00206.html>.
+ Based on proposed patch at
+ <https://lists.gnu.org/archive/html/bug-gnulib/2026-02/msg00043.html>.
+ * lib/wctype.in.h: Don't include <wchar.h> on mingw when it has already
+ been at least partially processed.
+
2026-02-27 Bruno Haible <bruno@clisp.org>
mbs_startswith: Add tests.
#error "Please include config.h first."
#endif
-#if @HAVE_WINT_T@
-/* Solaris 2.5 has a bug: <wchar.h> must be included before <wctype.h>. */
+/* Solaris 2.5 has a bug: <wchar.h> must be included before <wctype.h>.
+ But don't do it in very old mingw, when <wchar.h> is already partially
+ processed. */
+#if @HAVE_WINT_T@ && !(defined __MINGW32__ && defined _WCHAR_H)
# include <wchar.h>
#endif
/* Native Windows (mingw, MSVC) have declarations of towupper, towlower, and
isw* functions in <ctype.h>, <wchar.h> as well as in <wctype.h>. Include
<ctype.h>, <wchar.h> in advance to avoid rpl_ prefix being added to the
- declarations. */
-#if defined _WIN32 && ! defined __CYGWIN__
+ declarations. But don't do it in very old mingw, when <wchar.h> is already
+ partially processed. */
+#if defined _WIN32 && !defined __CYGWIN__ && !(defined __MINGW32__ && defined _WCHAR_H)
# include <ctype.h>
# include <wchar.h>
#endif