summaryrefslogtreecommitdiff
path: root/src/config.h.in
diff options
context:
space:
mode:
authorBen Smith <binjimin@gmail.com>2017-03-09 11:30:52 -0800
committerGitHub <noreply@github.com>2017-03-09 11:30:52 -0800
commit89b9c975d8f56291d708132b7ca2fdf57237415a (patch)
treedcb582401ce9d11918002e69a59390eda0e0416b /src/config.h.in
parent851f757b6681fefa965a20888e25596779b40402 (diff)
downloadwabt-89b9c975d8f56291d708132b7ca2fdf57237415a.tar.gz
wabt-89b9c975d8f56291d708132b7ca2fdf57237415a.tar.bz2
wabt-89b9c975d8f56291d708132b7ca2fdf57237415a.zip
Fix mingw build by defining _POSIX (#346)
mingw32 tries to support both VC runtime printf and a POSIX-compliant printf. It seems to randomly choose between the two, depending on arbitrary factors like header include order. This change forces us to always use the POSIX-compliant printf on mingw, and also changes the WABT_PRINTF_FORMAT attribute to use the POSIX-compliant tag too (gnu_printf, since printf defaults to ms_printf). This seems to resolve the issues for #324, as well as the ones I found in #342 as well.
Diffstat (limited to 'src/config.h.in')
-rw-r--r--src/config.h.in12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/config.h.in b/src/config.h.in
index 7dd91576..453e7985 100644
--- a/src/config.h.in
+++ b/src/config.h.in
@@ -66,8 +66,17 @@
#define WABT_INLINE inline
#define WABT_UNLIKELY(x) __builtin_expect(!!(x), 0)
#define WABT_LIKELY(x) __builtin_expect(!!(x), 1)
+
+#if __MINGW32__
+// mingw defaults to printf format specifier being ms_printf (which doesn't
+// understand 'llu', etc.) We always want gnu_printf, and force mingw to always
+// use mingw_printf, mingw_vprintf, etc.
+#define WABT_PRINTF_FORMAT(format_arg, first_arg) \
+ __attribute__((format(gnu_printf, (format_arg), (first_arg))))
+#else
#define WABT_PRINTF_FORMAT(format_arg, first_arg) \
__attribute__((format(printf, (format_arg), (first_arg))))
+#endif
#ifdef __cplusplus
#if __cplusplus >= 201103L
@@ -201,8 +210,7 @@ __inline unsigned __int64 __popcnt64(unsigned __int64 value) {
#endif
-/* Check For MINGW first, because it is also a GNU compiler */
-#if COMPILER_IS_MSVC || __MINGW32__
+#if COMPILER_IS_MSVC
/* print format specifier for size_t */
#if SIZEOF_SIZE_T == 4