Fixed bug 3609 - Windows build fails due to conflicting types for 'XINPUT_GAMEPAD_EX' Ozkan Sezer (In reply to Ryan C. Gordon from comment #9) > I've put this patch in as https://hg.libsdl.org/SDL/rev/7213ae46e870 ...can > you verify this works on the latest MinGW? > > Thanks, > --ryan. This patch is wrong: the structure in question has nothing to do with any gcc version in use. I suggest reverting this adding a conigury check for it, instead. Something like the following should do it: (configure needs regenerating.)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 46a05a7..4aec79f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1095,6 +1095,16 @@ elseif(WINDOWS)
#include <windows.h>
#include <xinput.h>
int main(int argc, char **argv) { }" HAVE_XINPUT_H)
+ check_c_source_compiles("
+ #include <windows.h>
+ #include <xinput.h>
+ XINPUT_GAMEPAD_EX x1;
+ int main(int argc, char **argv) { }" HAVE_XINPUT_GAMEPAD_EX)
+ check_c_source_compiles("
+ #include <windows.h>
+ #include <xinput.h>
+ XINPUT_STATE_EX s1;
+ int main(int argc, char **argv) { }" HAVE_XINPUT_STATE_EX)
else()
check_include_file(xinput.h HAVE_XINPUT_H)
endif()
diff --git a/configure b/configure
index 5bb39e7..e7300c1 100755
--- a/configure
+++ b/configure
@@ -22687,6 +22687,44 @@ if test "x$ac_cv_header_xinput_h" = xyes; then :
fi
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+#include <windows.h>
+#include <xinput.h>
+XINPUT_GAMEPAD_EX x1;
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ have_xinput_gamepadex=yes
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+#include <windows.h>
+#include <xinput.h>
+XINPUT_STATE_EX s1;
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ have_xinput_stateex=yes
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
if test x$have_ddraw = xyes; then
@@ -22713,6 +22751,16 @@ $as_echo "#define HAVE_DXGI_H 1" >>confdefs.h
$as_echo "#define HAVE_XINPUT_H 1" >>confdefs.h
fi
+ if test x$have_xinput_gamepadex = xyes; then
+
+$as_echo "#define HAVE_XINPUT_GAMEPAD_EX 1" >>confdefs.h
+
+ fi
+ if test x$have_xinput_stateex = xyes; then
+
+$as_echo "#define HAVE_XINPUT_STATE_EX 1" >>confdefs.h
+
+ fi
SUMMARY_video="${SUMMARY_video} directx"
SUMMARY_audio="${SUMMARY_audio} directx"
diff --git a/configure.in b/configure.in
index 2a9007e..769ea81 100644
--- a/configure.in
+++ b/configure.in
@@ -2801,6 +2801,16 @@ AC_HELP_STRING([--enable-directx], [use DirectX for Windows audio/video [[defaul
AC_CHECK_HEADER(dxgi.h, have_dxgi=yes)
AC_CHECK_HEADER(xaudio2.h, have_xaudio2=yes)
AC_CHECK_HEADER(xinput.h, have_xinput=yes)
+ AC_TRY_COMPILE([
+#include <windows.h>
+#include <xinput.h>
+XINPUT_GAMEPAD_EX x1;
+ ],[],[have_xinput_gamepadex=yes])
+ AC_TRY_COMPILE([
+#include <windows.h>
+#include <xinput.h>
+XINPUT_STATE_EX s1;
+ ],[],[have_xinput_stateex=yes])
if test x$have_ddraw = xyes; then
AC_DEFINE(HAVE_DDRAW_H, 1, [ ])
@@ -2817,6 +2827,12 @@ AC_HELP_STRING([--enable-directx], [use DirectX for Windows audio/video [[defaul
if test x$have_xinput = xyes; then
AC_DEFINE(HAVE_XINPUT_H, 1, [ ])
fi
+ if test x$have_xinput_gamepadex = xyes; then
+ AC_DEFINE(HAVE_XINPUT_GAMEPAD_EX, 1, [ ])
+ fi
+ if test x$have_xinput_stateex = xyes; then
+ AC_DEFINE(HAVE_XINPUT_STATE_EX, 1, [ ])
+ fi
SUMMARY_video="${SUMMARY_video} directx"
SUMMARY_audio="${SUMMARY_audio} directx"
diff --git a/include/SDL_config.h.cmake b/include/SDL_config.h.cmake
index c9a5327..2f236b9 100644
--- a/include/SDL_config.h.cmake
+++ b/include/SDL_config.h.cmake
@@ -55,6 +55,8 @@
#cmakedefine HAVE_XAUDIO2_H @HAVE_XAUDIO2_H@
#cmakedefine HAVE_XINPUT_H @HAVE_XINPUT_H@
#cmakedefine HAVE_DXGI_H @HAVE_DXGI_H@
+#cmakedefine HAVE_XINPUT_GAMEPAD_EX @HAVE_XINPUT_GAMEPAD_EX@
+#cmakedefine HAVE_XINPUT_STATE_EX @HAVE_XINPUT_STATE_EX@
/* Comment this if you want to build without any C library requirements */
#cmakedefine HAVE_LIBC 1
diff --git a/include/SDL_config.h.in b/include/SDL_config.h.in
index f698cb2..87a5b70 100644
--- a/include/SDL_config.h.in
+++ b/include/SDL_config.h.in
@@ -55,6 +55,8 @@
#undef HAVE_DSOUND_H
#undef HAVE_DXGI_H
#undef HAVE_XINPUT_H
+#undef HAVE_XINPUT_GAMEPAD_EX
+#undef HAVE_XINPUT_STATE_EX
/* Comment this if you want to build without any C library requirements */
#undef HAVE_LIBC
diff --git a/src/core/windows/SDL_windows.h b/src/core/windows/SDL_windows.h
index 040da6c..2a00dd4 100644
--- a/src/core/windows/SDL_windows.h
+++ b/src/core/windows/SDL_windows.h
@@ -35,6 +35,7 @@
#endif
#include <windows.h>
+#include <basetyps.h> /* for REFIID with broken mingw.org headers */
/* Routines to convert from UTF8 to native Windows text */
#if UNICODE
diff --git a/src/core/windows/SDL_xinput.h b/src/core/windows/SDL_xinput.h
index 527bd35..74bfd38 100644
--- a/src/core/windows/SDL_xinput.h
+++ b/src/core/windows/SDL_xinput.h
@@ -101,13 +101,7 @@
/* typedef's for XInput structs we use */
-/* Don't redeclare these on MinGW with gcc >= 5.0.2 */
-#if defined(__MINGW32__) && (((__GNUC__ * 10000) + (__GNUC_MINOR__ * 100) + __GNUC_PATCHLEVEL__) >= 50002)
-#define HAS_XINPUT_GAMEPAD_EX
-#define HAS_XINPUT_STATE_EX
-#endif
-
-#ifndef HAS_XINPUT_GAMEPAD_EX
+#ifndef HAVE_XINPUT_GAMEPAD_EX
typedef struct
{
WORD wButtons;
@@ -121,7 +115,7 @@ typedef struct
} XINPUT_GAMEPAD_EX;
#endif
-#ifndef HAS_XINPUT_STATE_EX
+#ifndef HAVE_XINPUT_STATE_EX
typedef struct
{
DWORD dwPacketNumber;