git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 05/12] MINGW: git-compat-util.h: use inttypes.h for printf macros.

From
Marat Radchenko <marat@slonopotamus.org>
Date
Apr 28, 2014, 13:51 UTC
Message-ID
<1398693097-24651-6-git-send-email-marat@slonopotamus.org>
In-Reply-To
<1398693097-24651-1-git-send-email-marat@slonopotamus.org>

Also, pass -D__USE_MINGW_ANSI_STDIO=0 to select MSVCRT-compatible macro definitions.

Signed-off-by: Marat Radchenko <marat@slonopotamus.org>
---
 compat/mingw.h    |  2 --
 compat/msvc.h     |  3 +++
 config.mak.uname  |  3 ++-
 git-compat-util.h | 11 ++++++-----
 4 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/compat/mingw.h b/compat/mingw.h
index 262b300..c502a22 100644
--- a/compat/mingw.h
+++ b/compat/mingw.h
@@ -342,8 +342,6 @@ static inline char *mingw_find_last_dir_sep(const char *path)
 }
 #define find_last_dir_sep mingw_find_last_dir_sep
 #define PATH_SEP ';'
-#define PRIuMAX "I64u"
-#define PRId64 "I64d"
 
 void mingw_open_html(const char *path);
 #define open_html mingw_open_html
diff --git a/compat/msvc.h b/compat/msvc.h
index 580bb55..cb41ce3 100644
--- a/compat/msvc.h
+++ b/compat/msvc.h
@@ -15,6 +15,9 @@
 #define strtoull     _strtoui64
 #define strtoll      _strtoi64
 
+#define PRIuMAX "I64u"
+#define PRId64 "I64d"
+
 static __inline int strcasecmp (const char *s1, const char *s2)
 {
 	int size1 = strlen(s1);
diff --git a/config.mak.uname b/config.mak.uname
index 6c2e6df..e5edae6 100644
--- a/config.mak.uname
+++ b/config.mak.uname
@@ -321,6 +321,7 @@ ifeq ($(uname_S),Windows)
 	NO_PREAD = YesPlease
 	NEEDS_CRYPTO_WITH_SSL = YesPlease
 	NO_LIBGEN_H = YesPlease
+	NO_INTTYPES_H = UnfortunatelyYes
 	NO_POLL = YesPlease
 	NO_SYMLINK_HEAD = YesPlease
 	NO_IPV6 = YesPlease
@@ -502,7 +503,7 @@ ifneq (,$(findstring MINGW,$(uname_S)))
 	NO_INET_NTOP = YesPlease
 	NO_POSIX_GOODIES = UnfortunatelyYes
 	DEFAULT_HELP_FORMAT = html
-	COMPAT_CFLAGS += -D__USE_MINGW_ACCESS -D_USE_32BIT_TIME_T -DNOGDI -Icompat -Icompat/win32
+	COMPAT_CFLAGS += -D__USE_MINGW_ANSI_STDIO=0 -D__USE_MINGW_ACCESS -D_USE_32BIT_TIME_T -DNOGDI -Icompat -Icompat/win32
 	COMPAT_CFLAGS += -DSTRIP_EXTENSION=\".exe\"
 	COMPAT_OBJS += compat/mingw.o compat/winansi.o \
 		compat/win32/pthread.o compat/win32/syslog.o \
diff --git a/git-compat-util.h b/git-compat-util.h
index f6d3a46..aa57a04 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -85,6 +85,12 @@
 #define _NETBSD_SOURCE 1
 #define _SGI_SOURCE 1
 
+#ifndef NO_INTTYPES_H
+#include <inttypes.h>
+#else
+#include <stdint.h>
+#endif
+
 #if defined(WIN32) && !defined(__CYGWIN__) /* Both MinGW and MSVC */
 # if defined (_MSC_VER) && !defined(_WIN32_WINNT)
 #  define _WIN32_WINNT 0x0502
@@ -146,11 +152,6 @@
 #include <netdb.h>
 #include <pwd.h>
 #include <sys/un.h>
-#ifndef NO_INTTYPES_H
-#include <inttypes.h>
-#else
-#include <stdint.h>
-#endif
 #ifdef NO_INTPTR_T
 /*
  * On I16LP32, ILP32 and LP64 "long" is the save bet, however
-- 
1.9.1
Previous: Felipe ContrerasNext: Erik Faye-Lund
Message 26 of 54 in “Towards MinGW(-W64) cross-compilation”
  1. Towards MinGW(-W64) cross-compilationMarat Radchenko, Apr 28, 2014
  2. 01/12 MINGW: config.mak.uname: add explicit way to request MinGW-buildMarat Radchenko, Apr 28, 2014
  3. Jonathan NiederApr 28, 2014
  4. 02/12 MINGW: compat/bswap.h: include stdint.hMarat Radchenko, Apr 28, 2014
  5. Erik Faye-LundApr 28, 2014
  6. Marat RadchenkoApr 28, 2014
  7. Erik Faye-LundApr 28, 2014
  8. 03/12 MINGW: compat/mingw.h: do not attempt to redefine lseek on mingw-w64Marat Radchenko, Apr 28, 2014
  9. Erik Faye-LundApr 28, 2014
  10. Marat RadchenkoApr 28, 2014
  11. Erik Faye-LundApr 28, 2014
  12. Torsten BögershausenApr 28, 2014
  13. Felipe ContrerasApr 28, 2014
  14. Erik Faye-LundApr 28, 2014
  15. 04/12 Makefile: introduce CROSS_COMPILE variableMarat Radchenko, Apr 28, 2014
  16. Jonathan NiederApr 28, 2014
  17. Felipe ContrerasApr 28, 2014
  18. Marat RadchenkoApr 28, 2014
  19. Jonathan NiederApr 28, 2014
  20. Marat RadchenkoApr 28, 2014
  21. Felipe ContrerasApr 28, 2014
  22. Marat RadchenkoApr 28, 2014
  23. Felipe ContrerasApr 28, 2014
  24. Jonathan NiederApr 28, 2014
  25. Felipe ContrerasApr 28, 2014
  26. 05/12 MINGW: git-compat-util.h: use inttypes.h for printf macros.Marat Radchenko, Apr 28, 2014
  27. Erik Faye-LundApr 28, 2014
  28. Marat RadchenkoApr 28, 2014
  29. Erik Faye-LundApr 28, 2014
  30. 06/12 MSVC: config.mak.uname: drop -D__USE_MINGW_ACCESS from compile definitionsMarat Radchenko, Apr 28, 2014
  31. Erik Faye-LundApr 28, 2014
  32. 07/12 MINGW: config.mak.uname: reorganize MINGW settingsMarat Radchenko, Apr 28, 2014
  33. Erik Faye-LundApr 28, 2014
  34. Marat RadchenkoApr 28, 2014
  35. Erik Faye-LundApr 28, 2014
  36. Marat RadchenkoApr 28, 2014
  37. 08/12 MINGW: config.mak.uname allow using CURL for non-msysGit buildsMarat Radchenko, Apr 28, 2014
  38. Erik Faye-LundApr 28, 2014
  39. Marat RadchenkoApr 28, 2014
  40. Erik Faye-LundApr 28, 2014
  41. 09/12 MINGW: config.mak.uname: drop -DNOGDIMarat Radchenko, Apr 28, 2014
  42. Erik Faye-LundApr 28, 2014
  43. 10/12 MINGW: config.mak.uname: drop USE_NED_ALLOCATORMarat Radchenko, Apr 28, 2014
  44. Erik Faye-LundApr 28, 2014
  45. Jonathan NiederApr 28, 2014
  46. Marat RadchenkoApr 29, 2014
  47. Felipe ContrerasApr 29, 2014
  48. Felipe ContrerasApr 28, 2014
  49. Philip OakleyApr 28, 2014
  50. 11/12 MINGW: do not fail at redefining pid_t on MinGW-W64Marat Radchenko, Apr 28, 2014
  51. Erik Faye-LundApr 28, 2014
  52. 12/12 MINGW: compat/mingw.h: drop fork() definitionMarat Radchenko, Apr 28, 2014
  53. Erik Faye-LundApr 28, 2014
  54. Erik Faye-LundApr 28, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.