Hi, I recently upgraded to the latest version 3.22.2 of the MinGW runtime from mingw.org. Building GDB 7.12 with the updated system headers produces many compilation errors of the following 2 kinds:
1. Problems with wchar.h: gcc -DHAVE_CONFIG_H -I. -I../.././gnulib/import -I.. -O2 -gdwarf-4 -g3 -D__USE_MINGW_ACCESS -MT dirname-lgpl.o -MD -MP -MF .deps/dirname-lgpl.Tpo -c -o dirname-lgpl.o ../.././gnulib/import/dirname-lgpl.c In file included from ../.././gnulib/import/dirname-lgpl.c:23:0: ./wchar.h:514:1: error: unknown type name 'mbstate_t' _GL_FUNCDECL_RPL (mbsinit, int, (const mbstate_t *ps)); ^ ./wchar.h:539:1: error: unknown type name 'mbstate_t' _GL_FUNCDECL_RPL (mbrtowc, size_t, ^ ./wchar.h:593:1: error: unknown type name 'mbstate_t' _GL_FUNCDECL_RPL (mbsrtowcs, size_t, ^ 2. Problems with wctype.h: gcc -DHAVE_CONFIG_H -I. -I../.././gnulib/import -I.. -O2 -gdwarf-4 -g3 -D__USE_MINGW_ACCESS -MT fnmatch.o -MD -MP -MF .deps/fnmatch.Tpo -c -o fnmatch.o ../.././gnulib/import/fnmatch.c In file included from ./wctype.h:59:0, from d:\usr\include\ctype.h:55, from ../.././gnulib/import/fnmatch.c:33: d:\usr\include\wctype.h:140:43: error: redefinition of 'iswalnum' __CRT_INLINE __cdecl __MINGW_NOTHROW int iswalnum (wint_t wc) ^ In file included from ./wctype.h:59:0, from d:\usr\include\wchar.h:61, from ./wchar.h:84, from ./wctype.h:45, from d:\usr\include\ctype.h:55, from ../.././gnulib/import/fnmatch.c:33: d:\usr\include\wctype.h:140:43: note: previous definition of 'iswalnum' was here __CRT_INLINE __cdecl __MINGW_NOTHROW int iswalnum (wint_t wc) ^ And the same for many other isw* functions. Both of these problems happen because MinGW headers sometimes exclude portions of their content, depending on which other standard header included them. Specifically, if wchar.h is included from string.h, only a part of wchar.h is processed, and that part doesn't include the definition of mbstate_t. Similarly, if wctype.h is included from ctype.h, the wctype.h's idempotency guard is not processed, so wctype.h could be processed again if included later, causing conflicts with itself. The corresponding Gnulib headers, wchar.h and wctype.c, don't expect that to happen. When they #include_next the corresponding system header, they assume that all of it was processed, and all of the symbols, macros, data types, and prototypes defined by the C standard for those headers are now defined, and can be used after #include_next. The latest MinGW runtime violates that assumption, which causes the above errors. I'm not sure what would be the best way of avoiding these errors, but I certainly hope some Gnulib solution could be found and implemented, because otherwise many projects will fail to compile with MinGW. TIA.