当前版本的mingw64是否与SDL库不兼容?编译器错误,之前没有任何错误

时间:2017-03-02 16:13:08

标签: c++ mingw sdl mingw-w64

我认为最近对mingw64的更新破坏了与SDL库的兼容性,但我不确定。

有任何已知的解决方法吗?是否容易恢复到已知的工作版本?我不经常编译这个并且对它很不熟悉。

这是编译器错误:

CC src/haptic/windows/SDL_syshaptic.o
In file included from src/haptic/windows/SDL_syshaptic.c:34:0:
src/haptic/windows/../../joystick/windows/SDL_dxjoystick_c.h:69:3: error: conflicting types for 'XINPUT_GAMEPAD_EX'
 } XINPUT_GAMEPAD_EX;
   ^~~~~~~~~~~~~~~~~
In file included from src/haptic/windows/../../joystick/windows/SDL_dxjoystick_c.h:42:0,
                 from src/haptic/windows/SDL_syshaptic.c:34:
C:/msys64/mingw64/x86_64-w64-mingw32/include/xinput.h:182:3: note: previous declaration of 'XINPUT_GAMEPAD_EX' was here
 } XINPUT_GAMEPAD_EX, *PXINPUT_GAMEPAD_EX;
   ^~~~~~~~~~~~~~~~~
In file included from src/haptic/windows/SDL_syshaptic.c:34:0:
src/haptic/windows/../../joystick/windows/SDL_dxjoystick_c.h:75:3: error: conflicting types for 'XINPUT_STATE_EX'
 } XINPUT_STATE_EX;
   ^~~~~~~~~~~~~~~
In file included from src/haptic/windows/../../joystick/windows/SDL_dxjoystick_c.h:42:0,
                 from src/haptic/windows/SDL_syshaptic.c:34:
C:/msys64/mingw64/x86_64-w64-mingw32/include/xinput.h:192:3: note: previous declaration of 'XINPUT_STATE_EX' was here
 } XINPUT_STATE_EX, *PXINPUT_STATE_EX;
   ^~~~~~~~~~~~~~~
make[2]: *** [Makefile:168: src/haptic/windows/SDL_syshaptic.o] Error 1
make[2]: Leaving directory '/c/{redacted}/sdl2'
make[1]: *** [Makefile:24: sdl2] Error 2
make[1]: Leaving directory '/c/{redacted}'
make: *** [Makefile:13: all] Error 2

1 个答案:

答案 0 :(得分:1)

好的,看起来两个文件中的typedef签名完全相同,所以只要你注释掉这段代码:

typedef struct
{
    WORD wButtons;
    BYTE bLeftTrigger;
    BYTE bRightTrigger;
    SHORT sThumbLX;
    SHORT sThumbLY;
    SHORT sThumbRX;
    SHORT sThumbRY;
    DWORD dwPaddingReserved;
} XINPUT_GAMEPAD_EX;

typedef struct
{
    DWORD dwPacketNumber;
    XINPUT_GAMEPAD_EX Gamepad;
} XINPUT_STATE_EX;

在“xinput.h”或“SDL_dxjoystick_c.h”中,它将允许代码编译。

这显然只是一个临时措施,我认为SDL库代码可能需要更新才能保持与最新mingw代码的兼容性。