On Sat, Jan 31, 2026 at 09:50:28AM +0200, Eli Zaretskii wrote: > > As Eli's patch showed, it appears to be unnecessary on the MinGW > > system he is using to include wchar.h in the Gnulib wchar.h. > > You mean, include wchar.h in the Gnulib wctype.h, right?
Sorry, I found them hard to keep straight. > > Another idea is, that since the problem comes about when including from > > system wchar.h, that is included from Gnulib wchar.h, some symbol could > > be defined in Gnulib wchar.h before including <ctype.h>. The Gnulib > > include guard symbol _GL_WCTYPE_H isn't defined until after wchar.h is > > included but there could be another one. > > This won't work, because Gnulib wchar.h does NOT include wctype.h. > > In file included from ./wctype.h:56, > > from d:\usr\include\wchar.h:62, > > from ./wchar.h:77, > > from btowc.c:21: > > ./wchar.h:1135:10: error: unknown type name 'mbstate_t' Here the chain of inclusions goes: btowc.c -> ./wchar.h => d:\usr\include\wchar.h => ./wctype.h => ./wchar.h Whatever is #defined in ./wchar.h before d:\usr\include\wchar.h is included would be visible in ./wctype.h. Hence if its not possible to detect that we are inside the system wchar.h (d:\usr\include\wchar.h) by checking defined symbols, it would still be possible if we were being included from Gnulib wchar.h indirectly.
