Search code examples
c++mingwsdlmingw-w64

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


I think a recent update to mingw64 broke compatibility with the SDL libraries, but I'm not sure.

Are there any known workarounds? Is it easy to revert back to a known working version? I don't compile with this very often and am pretty unfamiliar with it.

Here's the compiler error:

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

Solution

  • Okay, it looks like the typedef signatures in both files are exactly the same, so as long as you comment out this code:

    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;
    

    in either "xinput.h" or "SDL_dxjoystick_c.h" it will allow the code to compile.

    This is obviously just a temporary measure, I think the SDL library code probably needs an update to maintain compatibility with the latest mingw code.