On Thursday 13 January 2022 23:22:10 Martin Storsjö wrote:
> On Wed, 12 Jan 2022, Pali Rohár wrote:
> 
> > Original MSVC 6.0 msvcrt.dll library does not provide _vscprintf()
> > function. MinGW-w64 __ms_snprintf() and __ms_vsnprintf() implementations
> > call _vscprintf() function. So include fallback _vscprintf() implementation
> > into MinGW-w64 crt code to allow applications to use snprintf() with
> > original MSVC 6.0 msvcrt.dll library.
> > ---
> > mingw-w64-crt/Makefile.am              |  1 +
> > mingw-w64-crt/lib-common/msvcrt.def.in |  4 ++
> > mingw-w64-crt/misc/_vscprintf.c        | 72 ++++++++++++++++++++++++++
> > 3 files changed, 77 insertions(+)
> > create mode 100644 mingw-w64-crt/misc/_vscprintf.c
> > 
> > diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am
> > index e6b644ec1d44..1be9250c1e53 100644
> > --- a/mingw-w64-crt/Makefile.am
> > +++ b/mingw-w64-crt/Makefile.am
> > @@ -282,6 +282,7 @@ src_msvcrt32=\
> >   misc/_create_locale.c \
> >   misc/_free_locale.c \
> >   misc/_get_current_locale.c \
> > +  misc/_vscprintf.c \
> >   misc/lc_locale_func.c \
> >   misc/wassert.c
> > 
> > diff --git a/mingw-w64-crt/lib-common/msvcrt.def.in 
> > b/mingw-w64-crt/lib-common/msvcrt.def.in
> > index 0ea9d388fbe4..17bc7e9a076e 100644
> > --- a/mingw-w64-crt/lib-common/msvcrt.def.in
> > +++ b/mingw-w64-crt/lib-common/msvcrt.def.in
> > @@ -1111,7 +1111,11 @@ _vprintf_l
> > _vprintf_p
> > _vprintf_p_l
> > _vprintf_s_l
> > +#ifdef DEF_I386
> > +; _vscprintf Replaced by emu
> > +#else
> > _vscprintf
> > +#endif
> 
> We've got neater macros that avoid needing to spend many lines on this; you
> can make it F_NON_I386(_vscprintf) instead of spelling out the ifdef. See
> def-include/func.def.in for the full set of macros you can use for
> conditional availability.

Ok!

> > +int (__cdecl *__MINGW_IMP_SYMBOL(_vscprintf))(const char * __restrict__, 
> > va_list) = init_vscprintf;
> 
> This provides __imp___vscprintf only, but not __vscprintf, while
> lib32_libmingwex_a-vsnprintf.o has an undefined reference to __vscprintf.
> 
> Linking still works, but this forces the linker to do an autoimport of the
> symbol, which is quite suboptimal. So it would be best if this object file
> would provide the prefix-less regular function too, which just calls what
> the __imp_ prefixed symbol points at.
> 
> // Martin

Do you mean adding following line into source unit?

int __cdecl _vscprintf(const char * __restrict__ format, va_list arglist) { 
return __MINGW_IMP_SYMBOL(_vscprintf)(format, arglist); }

Or is there any macro for this purpose?

I still have not fully caught how autoimport works, what is exact
difference between __imp_ and non-imp symbols and what is suboptimal on
__imp_ symbols...


_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to