From 23c68472557842b9c2706ba25d28711db3241081 Mon Sep 17 00:00:00 2001
From: Orgad Shaneh <orgads@gmail.com>
Date: Thu, 13 Feb 2020 09:25:02 +0200
Subject: [PATCH] Fix using gnu print

---
 bfd/bfd-in.h                | 2 +-
 bfd/bfd-in2.h               | 2 +-
 gdbsupport/format.h         | 6 +++++-
 gnulib/import/inttypes.in.h | 8 ++++----
 4 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/bfd/bfd-in.h b/bfd/bfd-in.h
index d81cbb791f..6c14fc5da5 100644
--- a/bfd/bfd-in.h
+++ b/bfd/bfd-in.h
@@ -158,7 +158,7 @@ typedef BFD_HOST_U_64_BIT symvalue;
 
 #if BFD_HOST_64BIT_LONG
 #define BFD_VMA_FMT "l"
-#elif defined (__MSVCRT__)
+#elif defined(__MSVCRT__) && !defined( __USE_MINGW_ANSI_STDIO)
 #define BFD_VMA_FMT "I64"
 #else
 #define BFD_VMA_FMT "ll"
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index 6f3e41da37..54e9c7a56d 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -165,7 +165,7 @@ typedef BFD_HOST_U_64_BIT symvalue;
 
 #if BFD_HOST_64BIT_LONG
 #define BFD_VMA_FMT "l"
-#elif defined (__MSVCRT__)
+#elif defined (__MSVCRT__) && !defined(__USE_MINGW_ANSI_STDIO)
 #define BFD_VMA_FMT "I64"
 #else
 #define BFD_VMA_FMT "ll"
diff --git a/gdbsupport/format.h b/gdbsupport/format.h
index 80f012a41a..17a5560283 100644
--- a/gdbsupport/format.h
+++ b/gdbsupport/format.h
@@ -23,7 +23,11 @@
 #include "gdbsupport/gdb_string_view.h"
 
 #if defined(__MINGW32__) && !defined(PRINTF_HAS_LONG_LONG)
-# define USE_PRINTF_I64 1
+# if !defined(__USE_MINGW_ANSI_STDIO)
+#  define USE_PRINTF_I64 1
+# else
+#  define USE_PRINTF_I64 0
+# endif
 # define PRINTF_HAS_LONG_LONG
 #else
 # define USE_PRINTF_I64 0
diff --git a/gnulib/import/inttypes.in.h b/gnulib/import/inttypes.in.h
index ed09db6e86..ae06fdedc8 100644
--- a/gnulib/import/inttypes.in.h
+++ b/gnulib/import/inttypes.in.h
@@ -187,7 +187,7 @@
 #ifdef INT64_MAX
 # if (@APPLE_UNIVERSAL_BUILD@ ? defined _LP64 : @INT64_MAX_EQ_LONG_MAX@)
 #  define _PRI64_PREFIX "l"
-# elif defined _MSC_VER || defined __MINGW32__
+# elif (defined _MSC_VER || defined __MINGW32__) && !defined(__USE_MINGW_ANSI_STDIO)
 #  define _PRI64_PREFIX "I64"
 # elif @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1
 #  define _PRI64_PREFIX _LONG_LONG_FORMAT_PREFIX
@@ -204,7 +204,7 @@
 #ifdef UINT64_MAX
 # if (@APPLE_UNIVERSAL_BUILD@ ? defined _LP64 : @UINT64_MAX_EQ_ULONG_MAX@)
 #  define _PRIu64_PREFIX "l"
-# elif defined _MSC_VER || defined __MINGW32__
+# elif (defined _MSC_VER || defined __MINGW32__) && !defined(__USE_MINGW_ANSI_STDIO)
 #  define _PRIu64_PREFIX "I64"
 # elif @HAVE_UNSIGNED_LONG_LONG_INT@ && ULONG_MAX >> 31 == 1
 #  define _PRIu64_PREFIX _LONG_LONG_FORMAT_PREFIX
@@ -680,7 +680,7 @@
 #ifdef INT64_MAX
 # if (@APPLE_UNIVERSAL_BUILD@ ? defined _LP64 : @INT64_MAX_EQ_LONG_MAX@)
 #  define _SCN64_PREFIX "l"
-# elif defined _MSC_VER || defined __MINGW32__
+# elif (defined _MSC_VER || defined __MINGW32__) && !defined(__USE_MINGW_ANSI_STDIO)
 #  define _SCN64_PREFIX "I64"
 # elif @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1
 #  define _SCN64_PREFIX _LONG_LONG_FORMAT_PREFIX
@@ -697,7 +697,7 @@
 #ifdef UINT64_MAX
 # if (@APPLE_UNIVERSAL_BUILD@ ? defined _LP64 : @UINT64_MAX_EQ_ULONG_MAX@)
 #  define _SCNu64_PREFIX "l"
-# elif defined _MSC_VER || defined __MINGW32__
+# elif (defined _MSC_VER || defined __MINGW32__) && !defined(__USE_MINGW_ANSI_STDIO)
 #  define _SCNu64_PREFIX "I64"
 # elif @HAVE_UNSIGNED_LONG_LONG_INT@ && ULONG_MAX >> 31 == 1
 #  define _SCNu64_PREFIX _LONG_LONG_FORMAT_PREFIX
-- 
2.25.0.windows.1

