| Summary: | xinput build failure with dxsdk | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Ozkan Sezer <sezeroz> |
| Component: | joystick | Assignee: | Ryan C. Gordon <icculus> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | CC: | amaranth72, philipp.wiesemann |
| Version: | HG 2.0 | ||
| Hardware: | All | ||
| OS: | Windows (All) | ||
|
Description
Ozkan Sezer
2015-11-08 22:15:36 UTC
OK, the following change fixes the build for me. Tested with VS2005, 2008 and 2013.
--- SDL2/src/core/windows/SDL_xinput.h~
+++ SDL2/src/core/windows/SDL_xinput.h
@@ -26,6 +26,7 @@
#ifdef HAVE_XINPUT_H
#include "SDL_windows.h"
+#define XINPUT_USE_9_1_0 /* dxsdk compatibility */
#include <xinput.h>
#ifndef XUSER_MAX_COUNT
@@ -146,9 +147,9 @@
typedef DWORD (WINAPI *XInputGetBatteryInformation_t)
(
- _In_ DWORD dwUserIndex,
- _In_ BYTE devType,
- _Out_ XINPUT_BATTERY_INFORMATION *pBatteryInformation
+ __in DWORD dwUserIndex,
+ __in BYTE devType,
+ __out XINPUT_BATTERY_INFORMATION *pBatteryInformation
);
extern int WIN_LoadXInputDLL(void);
MinGW build is broken due to the same struct redifinition and also
because of the _In_/_Out_ or __in/__out stuff, but I don't have a
fix for it.
OK, the following version fixes MinGW case, too.
--- SDL2/src/core/windows/SDL_xinput.h~
+++ SDL2/src/core/windows/SDL_xinput.h
@@ -26,6 +26,7 @@
#ifdef HAVE_XINPUT_H
#include "SDL_windows.h"
+#define XINPUT_USE_9_1_0 /* dxsdk compatibility */
#include <xinput.h>
#ifndef XUSER_MAX_COUNT
@@ -118,11 +119,13 @@
XINPUT_GAMEPAD_EX Gamepad;
} XINPUT_STATE_EX;
+#ifndef __MINGW32__
typedef struct _XINPUT_BATTERY_INFORMATION
{
BYTE BatteryType;
BYTE BatteryLevel;
} XINPUT_BATTERY_INFORMATION, *PXINPUT_BATTERY_INFORMATION;
+#endif
/* Forward decl's for XInput API's we load dynamically and use if available */
typedef DWORD (WINAPI *XInputGetState_t)
@@ -144,11 +147,19 @@
XINPUT_CAPABILITIES* pCapabilities /* [out] Receives the capabilities */
);
+#ifndef _MSC_VER
+#ifndef __in
+#define __in
+#endif
+#ifndef __out
+#define __out
+#endif
+#endif
typedef DWORD (WINAPI *XInputGetBatteryInformation_t)
(
- _In_ DWORD dwUserIndex,
- _In_ BYTE devType,
- _Out_ XINPUT_BATTERY_INFORMATION *pBatteryInformation
+ __in DWORD dwUserIndex,
+ __in BYTE devType,
+ __out XINPUT_BATTERY_INFORMATION *pBatteryInformation
);
extern int WIN_LoadXInputDLL(void);
This building failure was maybe fixed here: https://hg.libsdl.org/SDL/rev/31b7adf67756 Only the structure redefinition error is fixed, so not fully fixed:
1. Older MinGW-w64 versions doesn't handle _In_/_Out_ and __in/__out
stuff, so they need defining.
2. VS2005 still fails unless I replace those _In_/_Out_ with __in/__out.
So I suggest the following.
--- SDL2/src/core/windows/SDL_xinput.h~
+++ SDL2/src/core/windows/SDL_xinput.h
@@ -144,11 +144,19 @@
XINPUT_CAPABILITIES* pCapabilities /* [out] Receives the capabilities */
);
+#ifndef _MSC_VER
+#ifndef __in
+#define __in
+#endif
+#ifndef __out
+#define __out
+#endif
+#endif /* ! _MSC_VER */
typedef DWORD (WINAPI *XInputGetBatteryInformation_t)
(
- _In_ DWORD dwUserIndex,
- _In_ BYTE devType,
- _Out_ XINPUT_BATTERY_INFORMATION_EX *pBatteryInformation
+ __in DWORD dwUserIndex,
+ __in BYTE devType,
+ __out XINPUT_BATTERY_INFORMATION_EX *pBatteryInformation
);
extern int WIN_LoadXInputDLL(void);
Could the '_In_' and '_Out_' parts of the declaration simply be removed from SDL's code without issue, instead of making different compilers recognize them? From what I can tell (correct me if I'm wrong though), they're just macros that expand to nothing in normal circumstances. Yes, the annotations can actually be removed. They are used only by MSVC and aren't vital. Fixed, thanks! https://hg.libsdl.org/SDL/rev/ac5490d5aefc |