This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/77459] [6/7 Regression] undefined reference to `snprintf' when building mingw-w64 cross-compiler


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77459

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Does this help?


--- a/libstdc++-v3/src/c++11/debug.cc
+++ b/libstdc++-v3/src/c++11/debug.cc
@@ -540,10 +540,25 @@ namespace
   using _Error_formatter = __gnu_debug::_Error_formatter;
   using _Parameter = __gnu_debug::_Error_formatter::_Parameter;

+#ifdef _GLIBCXX_USE_C99_STDIO
   template<typename _Tp>
     int
     format_word(char* buf, int n, const char* fmt, _Tp s)
     { return std::min(__builtin_snprintf(buf, n, fmt, s), n - 1); }
+#else
+    int
+    format_word(char* buf, int n, const char* fmt, const char* s)
+    {
+      if ((int)__builtin_strlen(s) >= n)
+       s = "???";
+      return std::min(__builtin_sprintf(buf, fmt, s), n - 1);
+    }
+
+  template<typename _Tp>
+    int
+    format_word(char* buf, int n, const char* fmt, _Tp s)
+    { return std::min(__builtin_sprintf(buf, fmt, s), n - 1); }
+#endif

   void
   get_max_length(std::size_t& max_length)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]