[PATCH] Fix using gnu print on mingw

Orgad Shaneh via Gdb-patches
2021-10-25T07:53:09Z

---
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 286afc607a3..6bb9622a514 100644
--- a/bfd/bfd-in.h
+++ b/bfd/bfd-in.h
@@ -131,7 +131,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 669f250d0e5..dd74c4c8eb3 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -138,7 +138,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 921fca5e04d..75d12ae531a 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 e9ee500e3e6..b1f1f7edd00 100644
--- a/gnulib/import/inttypes.in.h
+++ b/gnulib/import/inttypes.in.h
@@ -171,7 +171,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 LONG_MAX >> 30 == 1
# define _PRI64_PREFIX _LONG_LONG_FORMAT_PREFIX
@@ -186,7 +186,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 ULONG_MAX >> 31 == 1
# define _PRIu64_PREFIX _LONG_LONG_FORMAT_PREFIX
@@ -583,7 +583,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 LONG_MAX >> 30 == 1
# define _SCN64_PREFIX _LONG_LONG_FORMAT_PREFIX
@@ -598,7 +598,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 ULONG_MAX >> 31 == 1
# define _SCNu64_PREFIX _LONG_LONG_FORMAT_PREFIX
--
2.25.1