This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB 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]

[patchv2] [mingw] Fix "%lld" compilation error


On Fri, 15 Jun 2012 17:57:16 +0200, Joel Brobecker wrote:
> > 2012-06-15  Jan Kratochvil  <jan.kratochvil@redhat.com>
> > 
> > 	* common/buffer.c: Include inttypes.h.
> > 	(buffer_xml_printf): Use PRIdMAX, PRIuMAX, PRIxMAX and PRIoMAX.
> 
> I vaguely remember us not necessarily wanting to use some of those,
> but I don't remember the details. Perhaps Mark remembers? It seems
> that gnulib might be dealing with portability issues for us...

Update, the previous patch broke x86_64 GNU/Linux build.


Thanks,
Jan


gdb/
2012-06-15  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* common/buffer.c: Include inttypes.h and stdint.h.
	(buffer_xml_printf): Use PRId64, PRIu64, PRIx64 and PRIo64.

--- a/gdb/common/buffer.c
+++ b/gdb/common/buffer.c
@@ -25,10 +25,12 @@
 
 #include "xml-utils.h"
 #include "buffer.h"
+#include "inttypes.h"
 
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
+#include <stdint.h>
 
 void
 buffer_grow (struct buffer *buffer, const char *data, size_t size)
@@ -139,16 +141,20 @@ buffer_xml_printf (struct buffer *buffer, const char *format, ...)
 		  switch (*f)
 		    {
 		    case 'd':
-		      sprintf (str, "%lld", va_arg (ap, long long));
+		      sprintf (str, "%" PRId64,
+			       (int64_t) va_arg (ap, long long));
 		      break;
 		    case 'u':
-		      sprintf (str, "%llu", va_arg (ap, unsigned long long));
+		      sprintf (str, "%" PRIu64,
+			       (uint64_t) va_arg (ap, unsigned long long));
 		      break;
 		    case 'x':
-		      sprintf (str, "%llx", va_arg (ap, unsigned long long));
+		      sprintf (str, "%" PRIx64,
+			       (uint64_t) va_arg (ap, unsigned long long));
 		      break;
 		    case 'o':
-		      sprintf (str, "%llo", va_arg (ap, unsigned long long));
+		      sprintf (str, "%" PRIo64,
+			       (uint64_t) va_arg (ap, unsigned long long));
 		      break;
 		    default:
 		      str = 0;


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