[Bug libstdc++/77459] [6/7 Regression] undefined reference to `snprintf' when building mingw-w64 cross-compiler
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Sep 27 13:12:00 GMT 2016
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)
More information about the Gcc-bugs
mailing list