Hi all,

This patch (vswprintf.txt) attempts to fix vsnwprintf for libstdc++
to_string. The next patch (OS.txt) is to disable the workaround in GCC.

Both patches are for trunk mingw-w64 and GCC.

Due to lack of time, I did a minimal amount of testing by compiling the
libstdc++-v3 testsuite, they seem to compile fine. Note that I did not
test linking and running, just the bare minimum to get it compiled.
Index: trunk/mingw-w64-headers/crt/wchar.h
===================================================================
--- trunk/mingw-w64-headers/crt/wchar.h (revision 5423)
+++ trunk/mingw-w64-headers/crt/wchar.h (working copy)
@@ -568,12 +568,22 @@
   return __mingw_vwprintf( __format, __local_argv );
 }
 
+/* For libstdc++ */
+#if defined(__cplusplus) && defined(__GNUC__)
 __mingw_ovr
-/* __attribute__((__format__ (gnu_wprintf, 2, 0))) */ __MINGW_ATTRIB_NONNULL(2)
+/* __attribute__((__format__ (gnu_wprintf, 3, 0))) */ __MINGW_ATTRIB_NONNULL(3)
+int vswprintf (wchar_t *__stream, size_t __n, const wchar_t *__format, 
__builtin_va_list __local_argv)
+{
+  return __mingw_vsnwprintf( __stream, __n, __format, __local_argv );
+}
+#else
+__mingw_ovr
+/* __attribute__((__format__ (gnu_printf, 2, 0))) */ __MINGW_ATTRIB_NONNULL(2)
 int vswprintf (wchar_t *__stream, const wchar_t *__format, __builtin_va_list 
__local_argv)
 {
   return __mingw_vswprintf( __stream, __format, __local_argv );
 }
+#endif /* defined(__cplusplus) && defined(__GNUC__) */
 
 /*#ifndef __NO_ISOCEXT */  /* externs in libmingwex.a */
 __mingw_ovr
Index: trunk/mingw-w64-headers/crt/stdio.h
===================================================================
--- trunk/mingw-w64-headers/crt/stdio.h (revision 5423)
+++ trunk/mingw-w64-headers/crt/stdio.h (working copy)
@@ -742,12 +742,22 @@
   return __mingw_vwprintf( __format, __local_argv );
 }
 
+/* For libstdc++ */
+#if defined(__cplusplus) && defined(__GNUC__)
 __mingw_ovr
+/* __attribute__((__format__ (gnu_wprintf, 3, 0))) */ __MINGW_ATTRIB_NONNULL(3)
+int vswprintf (wchar_t *__stream, size_t __n, const wchar_t *__format, 
__builtin_va_list __local_argv)
+{
+  return __mingw_vsnwprintf( __stream, __n, __format, __local_argv );
+}
+#else
+__mingw_ovr
 /* __attribute__((__format__ (gnu_printf, 2, 0))) */ __MINGW_ATTRIB_NONNULL(2)
 int vswprintf (wchar_t *__stream, const wchar_t *__format, __builtin_va_list 
__local_argv)
 {
   return __mingw_vswprintf( __stream, __format, __local_argv );
 }
+#endif /* defined(__cplusplus) && defined(__GNUC__) */
 
 #ifndef __NO_ISOCEXT  /* externs in libmingwex.a */
 __mingw_ovr
Index: libstdc++-v3/config/os/mingw32-w64/os_defines.h
===================================================================
--- libstdc++-v3/config/os/mingw32-w64/os_defines.h     (revision 191866)
+++ libstdc++-v3/config/os/mingw32-w64/os_defines.h     (working copy)
@@ -63,8 +63,8 @@
 // See libstdc++/20806.
 #define _GLIBCXX_HAVE_DOS_BASED_FILESYSTEM 1
 
-// See  libstdc++/37522.
-#define _GLIBCXX_HAVE_BROKEN_VSWPRINTF 1
+// See  libstdc++/37522. mingw-w64 stdio redirect for C++
+// #define _GLIBCXX_HAVE_BROKEN_VSWPRINTF 1
 
 // See libstdc++/43738
 // On native windows targets there is no ioctl function. And the existing

Attachment: signature.asc
Description: OpenPGP digital signature

------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to