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

Is the current version of mingw64 incompatible with the SDL libraries? Compiler errors where there weren't any before

我认为最近对 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

好的,看起来两个文件中的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 代码的兼容性。