summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crawl-ref/source/AppHdr.h20
-rw-r--r--crawl-ref/source/Makefile2
2 files changed, 21 insertions, 1 deletions
diff --git a/crawl-ref/source/AppHdr.h b/crawl-ref/source/AppHdr.h
index ae7ff97eb2..7497d8022b 100644
--- a/crawl-ref/source/AppHdr.h
+++ b/crawl-ref/source/AppHdr.h
@@ -418,8 +418,28 @@ static inline void UNUSED(const volatile T &)
#ifdef __GNUC__
// show warnings about the format string
+#ifdef TARGET_COMPILER_MINGW
+// mingw32 / mingw-w64 compiler
+// If __MINGW_PRINTF_FORMAT is defined, mingw-w64 will try to use a C99 printf
+// However, stdio.h must be included to have a C99 printf for use with
+// __attribute__((format(...)).
+#ifdef __cplusplus
+#include <cstdio>
+#else
+#include <stdio.h>
+#endif
+// Fall back to standard printf if necessary
+#ifndef __MINGW_PRINTF_FORMAT
+#define __MINGW_PRINTF_FORMAT printf
+#endif
+// Use the mingw32/mingw-w64 C99-specific printf function to check format
+# define PRINTF(x, dfmt) const char *format dfmt, ...) \
+ __attribute__((format (__MINGW_PRINTF_FORMAT, x+1, x+2))
+#else
+// standard GNU-compatible compiler (i.e., not mingw32/mingw-w64)
# define PRINTF(x, dfmt) const char *format dfmt, ...) \
__attribute__((format (printf, x+1, x+2))
+#endif
#else
# define PRINTF(x, dfmt) const char *format dfmt, ...
#endif
diff --git a/crawl-ref/source/Makefile b/crawl-ref/source/Makefile
index 286110a5b4..e92d1b9b81 100644
--- a/crawl-ref/source/Makefile
+++ b/crawl-ref/source/Makefile
@@ -192,7 +192,7 @@ ifneq (,$(findstring MINGW,$(uname_S)))
NEED_LIBW32C = YesPlease
BUILD_PCRE = YesPlease
BUILD_ZLIB = YesPlease
- DEFINES_L += -DWINMM_PLAY_SOUNDS
+ DEFINES_L += -DWINMM_PLAY_SOUNDS -D__USE_MINGW_ANSI_STDIO
EXTRA_LIBS += -lwinmm
ifdef TILES
EXTRA_LIBS += -lmingw32 -lgdi32 -lwinmm contrib/install/$(ARCH)/lib/libSDLmain.a -mwindows