From bcb1270f23c2a7ce878e0fd3b4edbacc371539c8 Mon Sep 17 00:00:00 2001 From: Cao Jiaxi Date: Thu, 9 May 2019 17:44:12 -0400 Subject: [PATCH] osdep: Fix mingw compilation regarding stdio formats I encountered the following compilation error on mingw: /mnt/d/qemu/include/qemu/osdep.h:97:9: error: '__USE_MINGW_ANSI_STDIO' macro redefined [-Werror,-Wmacro-redefined] \#define __USE_MINGW_ANSI_STDIO 1 ^ /mnt/d/llvm-mingw/aarch64-w64-mingw32/include/_mingw.h:433:9: note: previous definition is here \#define __USE_MINGW_ANSI_STDIO 0 /* was not defined so it should be 0 */ It turns out that __USE_MINGW_ANSI_STDIO must be set before any system headers are included, not just before stdio.h. Backports commit 946376c21be1cd9dcc3c7936b204b113781603f7 from qemu --- qemu/include/qemu/osdep.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/qemu/include/qemu/osdep.h b/qemu/include/qemu/osdep.h index 021a4da2..166f84f0 100644 --- a/qemu/include/qemu/osdep.h +++ b/qemu/include/qemu/osdep.h @@ -72,16 +72,16 @@ typedef __float128 _Float128; #endif #endif +/* enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later) */ +#ifdef __MINGW32__ +#define __USE_MINGW_ANSI_STDIO 1 +#endif + #include #include #include "unicorn/platform.h" #include #include - -/* enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later) */ -#ifdef __MINGW32__ -#define __USE_MINGW_ANSI_STDIO 1 -#endif #include #ifndef _MSC_VER