[Mingw-users] btowc problem

Zurück zum Archiv-Index
Eli Zaretskii eliz****@gnu*****
Thu Jul 2 00:08:09 JST 2020


> From: Keith Marshall <keith****@users*****>
> Date: Tue, 30 Jun 2020 21:33:14 +0100
> 
> I'm not sure that I entirely follow your logic here; maybe it does, but
> I'm not convinced.  I think we can agree on this:
> 
>   - Compile with <wchar.t> from mingwrt-5.2.x, and the object module
>     will contain an unresolved symbol reference for btowc; _link_ that
>     with mingwrt-5.2.x libraries, and that reference will be resolved
>     to the implementation in libmingwex.a, (or libmingwex.dll.a), but
>     link with mingwrt-5.3.x, and the link _should_ fail, (because the
>     btowc symbol isn't present in libmingwex.a, or libmingwex.dll.a,
>     and nor _should_ there be a fall-back in libmsvcrt.a ... but wait;
>     there _is_ such a fall-back, and therein lies the explanation for
>     your problem ... the linker believes that it can resolve the btowc
>     symbol from MSVCRT.DLL, which isn't the case prior to Win-Vista,
>     (and even from Vista onward, we want to ignore it).

Agreed.

>   - Compile with <wchar.h> from mingwrt-5.3.x, and the object module
>     will contain an unresolved reference to __msvcrt_btowc; link that
>     with mingwrt-5.3.x libraries, an linking should succeed, but with
>     mingwrt-5.2.x libraries, it _must_ fail.

Right.

> And ... in writing this, I think I've walked into the real explanation,
> which in turn leads to the solution: we need to rebuild libmsvcrt.a,
> omitting the offending symbols -- i.e. all of those which we want to be
> accessed exclusively via __msvcrt_redirect references in libmingwex.a.

I'm probably missing something, but how can this work if one links a
program compiled under mingwrt-5.3.x, but with some libraries compiled
by older mingwrt?  Those older libraries will want to resolve btowc
and the other wchar.h functions which were previously in libmingwex.
If you want libmsvcrt.a to solve this, you will have to put in there
btowc etc. that call back into libmingwex.a's __msvcrt_* versions, no?
And that would make libmsvcrt.a not really an import library anymore,
although maybe we don't care?

My suggestion was to add to 5.3.x libmingwex.a implementations of
btowc etc. that simply call the corresponding __msvcrt_* functions, so
that libraries compiled by older MinGW versions could still be happy
when linked under the newer mingwrt.



More information about the MinGW-Users mailing list
Zurück zum Archiv-Index