When building the latest snapshot of GDB 13 with mingw.org's MinGW tools, I bumped into the following compilation error:
CC bfdio.lo bfdio.c: In function '_bfd_real_fopen': bfdio.c:130:28: error: implicit declaration of function '___lc_codepage_func' [-Werror=implicit-function-declaration] 130 | const unsigned int cp = ___lc_codepage_func(); | ^~~~~~~~~~~~~~~~~~~ This happens because the proper prototype of ___lc_codepage_func is defined under a condition that is only valid for MinGW64: #if defined(__MINGW64_VERSION_MAJOR) && __MINGW64_VERSION_MAJOR < 9 /* This prototype was added to locale.h in version 9.0 of MinGW-w64. */ _CRTIMP unsigned int __cdecl ___lc_codepage_func(void); #endif mingw.org's MinGW doesn't define __MINGW64_VERSION_MAJOR, and it lacks the prototype of ___lc_codepage_func in all of its versions. Therefore, I suggest the following fix to satisfy both flavors of MinGW: --- bfd/bfdio.c~0 2022-12-17 03:47:10.000000000 +0200 +++ bfd/bfdio.c 2022-12-17 16:45:38.067750000 +0200 @@ -31,8 +31,10 @@ #include <locale.h> #endif -#if defined(__MINGW64_VERSION_MAJOR) && __MINGW64_VERSION_MAJOR < 9 -/* This prototype was added to locale.h in version 9.0 of MinGW-w64. */ +#if (defined(__MINGW64_VERSION_MAJOR) && __MINGW64_VERSION_MAJOR < 9) \ + || (defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR)) +/* This prototype was added to locale.h in version 9.0 of MinGW-w64, + and is absent from all versions of mingw.org's MinGW. */ _CRTIMP unsigned int __cdecl ___lc_codepage_func(void); #endif