> Date: Mon, 29 Jun 2020 21:01:22 +0300 > From: Eli Zaretskii <eliz****@gnu*****> > > /* No explicit ISO-C99 compatibility has been requested; map calls > * to these functions to delegate to any MSVCRT.DLL implementations > * which may be available, or to fall back to the MinGW replacement > * implementations, when necessary. > */ > # define __mingw_redirect(NAME) __msvcrt_##NAME > > >From this I understand that __msvcrt_btowc is supposed to call the MS > implementation in MSVCRT.DLL when that is available, and otherwise > fall back on libmingwex. Why does this not happen? Moreover, even if > I replace the call to btowc by an explicit call to __mingw_btowc, GDB > still refuses to run with the same error message. What am I missing? Answering my own question: it's because the above can only work if _all_ the parts of a program were compiled and linked win MinGW runtime 5.3.x. And therein lies the problem: I think this assumption is unrealistic. In particular, libraries tend to be built once, and then used to link programs even after upgrading MinGW runtime. In my case, I use libiconv compiled and linked with an older version of MinGW runtime: try "nm -A" on libiconv.a, and you will see something like this: d:/usr/lib/libiconv.a:iconv.o:0000bde0 t _wchar_to_loop_convert d:/usr/lib/libiconv.a:iconv.o:0000c490 t _wchar_to_loop_reset d:/usr/lib/libiconv.a:iconv.o: U _wcrtomb <<<<<<<<<<<<<<<< Another use case is building a C++ program that uses some ctype features: it might call _M_initialize_ctype, which is in libstdc++, and calls btowc. Here's an excerpt from disassembling gdb.exe: 00999f80 <__ZNSt5ctypeIwE19_M_initialize_ctypeEv>: 999f80: 57 push %edi 999f81: 56 push %esi 999f82: 89 ce mov %ecx,%esi 999f84: 53 push %ebx 999f85: 31 db xor %ebx,%ebx 999f87: 83 ec 10 sub $0x10,%esp 999f8a: eb 13 jmp 999f9f <__ZNSt5ctypeIwE19_M_initialize_ctypeEv+0x1f> [...] 999fac: c6 46 0c 00 movb $0x0,0xc(%esi) 999fb0: 31 db xor %ebx,%ebx 999fb2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 999fb8: 89 1c 24 mov %ebx,(%esp) 999fbb: e8 58 3e f5 ff call 8ede18 <_btowc> <<<<<<<<<<<< 999fc0: 66 89 84 5e 8e 00 00 mov %ax,0x8e(%esi,%ebx,2) (Btw, this probably means that a C++ program dynamically linked against libstdc++ will refuse to run on Windows XP or older.) So basically, I think that we must provide in libmingwex the wchar.h functions that might not be available in MSVCRT.DLL, so that programs could reliably work on XP and older systems. Or did I miss something?