Eli Zaretskii wrote in
<https://lists.gnu.org/archive/html/bug-texinfo/2026-01/msg00099.html>
about the old dead mingw.org's mingw distribution:

> >      gcc -DHAVE_CONFIG_H -I. -I../..   -Id:/usr/include  -Wno-cast-qual 
> > -Wno-conversion -Wno-float-equal -Wno-sign-compare -Wno-undef 
> > -Wno-unused-function -Wno-unused-parameter -Wno-float-conversion 
> > -Wimplicit-fallthrough -Wno-pedantic -Wno-sign-conversion -Wno-type-limits 
> > -Wno-unused-const-variable -Wno-unsuffixed-float-constants -Wno-error -O2 
> > -gdwarf-4 -g3 -MT libgnu_a-btowc.o -MD -MP -MF .deps/libgnu_a-btowc.Tpo -c 
> > -o libgnu_a-btowc.o `test -f 'btowc.c' || echo './'`btowc.c
> >      In file included from ./wctype.h:56,
> >                   from d:\usr\include\wchar.h:62,
> >                   from ./wchar.h:77,
> >                   from btowc.c:21:
> >      ./wchar.h:923:1: error: unknown type name 'mbstate_t'
> >        923 | _GL_FUNCDECL_RPL (mbsinit, int, (const mbstate_t *ps), );
> >        | ^~~~~~~~~~~~~~~~
> > ...
> > This is because the MinGW wchar.h includes wctype.h, so we include the
> > Gnulib's version of it, and that one then turns around and includes
> > wchar.h again.  But because the MinGW wchar.h was not yet completely
> > processed, mbstate_t is not yet defined.
> > 
> > I don't know how to solve this cleanly.

We have a technique for this situation in Gnulib. But it is fragile, therefore
let me ask one or two questions before applying it.

gnulib/lib/wctype.in.h has this piece of code:

-------------------------------------------------------------------------------
#if (defined __MINGW32__ && defined __CTYPE_H_SOURCED__)

/* Special invocation convention:
   - With MinGW 3.22, when <ctype.h> includes <wctype.h>, only some part of
     <wctype.h> is being processed, which doesn't include the idempotency
     guard.   */

#@INCLUDE_NEXT@ @NEXT_WCTYPE_H@

#else
/* Normal invocation convention.  */
-------------------------------------------------------------------------------

In your mingw <wchar.h>, is there some preprocessor definition, that we
could test (similar to __CTYPE_H_SOURCED__)?

Bruno




Reply via email to