From ac7bf2261a1bce19df33b96bc78880b8334064fa Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 22 Oct 2007 11:32:59 +0000 Subject: [PATCH] vswprintf() compilation fix for mingw32 with STLport 5.1 git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@49328 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/wxchar.h | 13 +++++++++++-- src/common/wxchar.cpp | 14 ++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/include/wx/wxchar.h b/include/wx/wxchar.h index c1fc4df61a..68b0168ad0 100644 --- a/include/wx/wxchar.h +++ b/include/wx/wxchar.h @@ -371,6 +371,14 @@ /* and there is a bug in D Mars tchar.h prior to 8.39.4n, so define as sprintf */ #define wxSprintf sprintf #endif + #elif defined(__MINGW32__) && ( defined(_STLPORT_VERSION) && _STLPORT_VERSION >= 0x510 ) + #if wxUSE_UNICODE + /* MinGW with STLPort 5.1 adds count to swprintf (C99) so prototype conversion see wxchar.cpp */ + int wxSprintf (wchar_t*, const wchar_t*, ...); + #else + /* MinGW with STLPort 5.1 has clashing defines for _stprintf so use sprintf */ + #define wxSprintf sprintf + #endif #else #define wxSprintf _stprintf #endif @@ -887,9 +895,10 @@ WXDLLIMPEXP_BASE bool wxOKlibc(); /* for internal use */ /* MinGW MSVCRT has non-standard vswprintf() (for MSVC compatibility - presumably) and normally _vsnwprintf() is used instead + presumably) and normally _vsnwprintf() is used instead (but as + STLPort 5.1 defines standard vswprintf(), don't do this for it) */ -#if defined(HAVE_VSWPRINTF) && defined(__MINGW32__) +#if defined(HAVE_VSWPRINTF) && defined(__MINGW32__) && !( defined(_STLPORT_VERSION) && _STLPORT_VERSION >= 0x510 ) #undef HAVE_VSWPRINTF #endif diff --git a/src/common/wxchar.cpp b/src/common/wxchar.cpp index 51b42ff374..449bc89f95 100644 --- a/src/common/wxchar.cpp +++ b/src/common/wxchar.cpp @@ -1250,6 +1250,20 @@ int WXDLLEXPORT wxSnprintf_(wxChar *buf, size_t len, const wxChar *format, ...) #endif //__DMC__ +#if defined(__MINGW32__) && ( defined(_STLPORT_VERSION) && _STLPORT_VERSION >= 0x510 ) + /* MinGW with STLPort 5.1 has clashing defines for _stprintf so use swprintf */ + /* STLPort 5.1 defines standard (C99) vswprintf() and swprintf() that takes count. */ + int wxSprintf (wchar_t * s, const wchar_t * format, ... ) + { + va_list arglist; + + va_start( arglist, format ); + int iLen = swprintf ( s, -1, format, arglist ); + va_end( arglist ); + return iLen ; + } +#endif // MINGW32 _STLPORT_VERSION >= 0x510 + // ---------------------------------------------------------------------------- // implement the standard IO functions for wide char if libc doesn't have them // ----------------------------------------------------------------------------