From: Eli Zaretskii <eliz@gnu.org>
To: Pedro Alves <palves@redhat.com>
Cc: brobecker@adacore.com, simon.marchi@polymtl.ca,
gdb-patches@sourceware.org
Subject: Re: GDB 7.99.91 MinGW compilation error in cli-script.c
Date: Wed, 24 May 2017 18:28:00 -0000 [thread overview]
Message-ID: <834lwam7n4.fsf@gnu.org> (raw)
In-Reply-To: <54594002-5d70-9ff8-c481-0cbfc8c68c7b@redhat.com> (message from Pedro Alves on Tue, 23 May 2017 10:53:47 +0100)
> Cc: brobecker@adacore.com, simon.marchi@polymtl.ca, gdb-patches@sourceware.org
> From: Pedro Alves <palves@redhat.com>
> Date: Tue, 23 May 2017 10:53:47 +0100
>
> >> It'd be useful for the archives if you expanded on which mingw versions
> >> and compilers you tested this on. Also likewise a short comment to
> >> the effect in the code would be likewise handy for future readers
> >
> > OK, will do.
Here's the final version; okay to commit?
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index a96e71f..d3a251b 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,10 @@
+2017-05-24 Eli Zaretskii <eliz@gnu.org>
+
+ * common/common-utils.h (REPLACE_TO_STRING) [__MINGW32__]: Define
+ to 1 if std::to_string is not available.
+ (std::to_string) [REPLACE_TO_STRING]: Provide a replacement
+ implementation.
+
2017-05-24 Yao Qi <yao.qi@linaro.org>
* rs6000-tdep.c (gdb_print_insn_powerpc): Remove.
diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c
index e0e27ef..2e5e397 100644
--- a/gdb/cli/cli-script.c
+++ b/gdb/cli/cli-script.c
@@ -806,7 +818,7 @@ user_args::insert_args (const char *line) const
if (p[4] == 'c')
{
- new_line += std::to_string (m_args.size ());
+ new_line += gdb::to_string (m_args.size ());
line = p + 5;
}
else
diff --git a/gdb/common/common-utils.h b/gdb/common/common-utils.h
index c331f0d..e3cd66e 100644
--- a/gdb/common/common-utils.h
+++ b/gdb/common/common-utils.h
@@ -22,6 +22,7 @@
#include <string>
#include <vector>
+#include <sstream>
/* If possible, define FUNCTION_NAME, a macro containing the name of
the function being defined. Since this macro may not always be
@@ -63,6 +64,47 @@ int xsnprintf (char *str, size_t size, const char *format, ...)
std::string string_printf (const char* fmt, ...)
ATTRIBUTE_PRINTF (1, 2);
+/* Returns a string representation of VAL. Replacement for C++11
+ std::to_string for hosts that lack it. */
+
+namespace gdb {
+
+#define REPLACE_TO_STRING 0
+
+#ifdef __MINGW32__
+/* mingw.org's MinGW runtime before version 5.0 needs the replacement
+ below. Tested with mingwrt-3.22.2 and mingwrt-5.0, and with
+ libstdc++ included with MinGW GCC 5.3.0. */
+# include <_mingw.h>
+/* We test __MINGW64_VERSION_MAJOR to exclude MinGW64, which doesn't
+ need this replacement. */
+# if !defined __MINGW64_VERSION_MAJOR && !defined _GLIBCXX_USE_C99
+# undef REPLACE_TO_STRING
+# define REPLACE_TO_STRING 1
+# endif
+#endif
+
+#if REPLACE_TO_STRING
+
+template <class T>
+inline std::string
+to_string (const T &val)
+{
+ std::stringstream ss;
+
+ ss << val;
+ return ss.str ();
+}
+
+#else /* !REPLACE_TO_STRING */
+
+using std::to_string;
+
+#endif
+
+#undef REPLACE_TO_STRING
+}
+
/* Make a copy of the string at PTR with LEN characters
(and add a null character at the end in the copy).
Uses malloc to get the space. Returns the address of the copy. */
next prev parent reply other threads:[~2017-05-24 18:28 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-04 19:44 GDB 7.99.91 available for testing Joel Brobecker
2017-05-08 14:53 ` Eli Zaretskii
2017-05-17 11:36 ` Yao Qi
2017-05-17 14:39 ` Eli Zaretskii
2017-05-08 15:00 ` GDB 7.99.91 MinGW compilation error in cli-script.c Eli Zaretskii
2017-05-14 3:19 ` Simon Marchi
2017-05-14 14:13 ` Eli Zaretskii
2017-05-17 14:31 ` Joel Brobecker
2017-05-17 16:01 ` Eli Zaretskii
2017-05-19 9:10 ` Eli Zaretskii
2017-05-19 9:49 ` Pedro Alves
2017-05-19 11:17 ` Eli Zaretskii
2017-05-19 11:23 ` Pedro Alves
2017-05-21 15:33 ` Eli Zaretskii
2017-05-22 15:26 ` Pedro Alves
2017-05-22 18:43 ` Eli Zaretskii
2017-05-23 9:53 ` Pedro Alves
2017-05-24 2:44 ` Eli Zaretskii
2017-05-25 10:05 ` Pedro Alves
2017-05-26 7:57 ` Eli Zaretskii
2017-05-26 11:52 ` Pedro Alves
2017-05-26 12:57 ` Eli Zaretskii
2017-05-26 13:58 ` Pedro Alves
2017-05-24 18:28 ` Eli Zaretskii [this message]
2017-05-24 19:37 ` Joel Brobecker
2017-05-25 10:12 ` Pedro Alves
2017-05-26 7:47 ` Eli Zaretskii
2017-05-26 10:54 ` Pedro Alves
2017-05-26 13:03 ` Eli Zaretskii
2017-05-26 14:10 ` Pedro Alves
2017-05-26 14:35 ` Eli Zaretskii
2017-05-26 14:45 ` Pedro Alves
2017-05-08 15:02 ` GDB 7.99.91 MinGW compilation warning in tui.c Eli Zaretskii
2017-05-09 10:17 ` Yao Qi
2017-05-13 8:12 ` Eli Zaretskii
2017-05-17 16:26 ` Yao Qi
2017-05-17 16:45 ` Eli Zaretskii
2017-05-17 18:21 ` Joel Brobecker
2017-05-19 8:02 ` Eli Zaretskii
2017-05-19 9:54 ` Pedro Alves
2017-05-19 11:14 ` Eli Zaretskii
2017-05-19 11:25 ` Pedro Alves
2017-05-19 12:51 ` Eli Zaretskii
2017-05-19 13:58 ` Pedro Alves
2017-05-19 14:40 ` Eli Zaretskii
2017-05-19 17:50 ` DJ Delorie
2017-05-19 17:55 ` Eli Zaretskii
2017-05-15 21:11 ` GDB 7.99.91 available for testing Simon Marchi
2017-05-16 13:51 ` Simon Marchi
2017-05-16 20:50 ` Yao Qi
2017-05-16 21:22 ` Simon Marchi
2017-05-16 21:40 ` Yao Qi
2017-05-17 11:31 ` [PATCH master/8.0] Add alias command to cmd_list_element Yao Qi
2017-05-17 12:16 ` Simon Marchi
2017-05-17 13:36 ` Yao Qi
2017-05-16 14:28 ` GDB 7.99.91 available for testing Joel Brobecker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=834lwam7n4.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=brobecker@adacore.com \
--cc=gdb-patches@sourceware.org \
--cc=palves@redhat.com \
--cc=simon.marchi@polymtl.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox