Game controller subsystem failing for SDL2.0.9 mingw-w64 and msvc

I compile sdl2 as a static library like so:

cmake.exe -DCMAKE_BUILD_TYPE=Debug -G "MinGW Makefiles"^
 -DCMAKE_EXE_LINKER_FLAGS="-fuse-ld=lld.exe" -DCMAKE_C_FLAGS="-target x86_64-windows-gnu" -DCMAKE_C_COMPILER="clang.exe" -DCMAKE_C_COMPILER_ID="Clang"^
 -DVIDEO_OPENGL=ON -DDIRECTX=OFF -DRENDER_D3D=OFF -DVIDEO_DUMMY=OFF -DVIDEO_OPENGLES=OFF -DVIDEO_VULKAN=OFF^
 -DDISKAUDIO=OFF -DDUMMYAUDIO=OFF^
 -DSDL_STATIC=ON -DSDL_SHARED=OFF -DSDL_TEST=OFF ..
cmake.exe --build . -- -j %NUMBER_OF_PROCESSORS%

I link against this static library like so:

SET ll_common_flags=-DLL_SLOW -DLL_DEV -fno-omit-frame-pointer -fno-optimize-sibling-calls -g^
 -target x86_64-windows-gnu -fuse-ld=lld.exe -Wall -Wextra -Wpedantic -Wfloat-equal -Wunreachable-code -Wshadow^
 -Wno-gnu

clang.exe %ll_common_flags% ..\code\sdl-ll.c -o sdl-ll.exe^
 -Wl,-subsystem,windows -I ..\sdl2-2.0.9-minimal\include -L ..\sdl2-2.0.9-minimal\build^
  -lmingw32 -lwinmm -lole32 -limm32 -loleaut32 -lgdi32 -luuid -lversion -lopengl32^
    -lSDL2maind -lSDL2d 

This line fails:

if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_GAMECONTROLLER | SDL_INIT_HAPTIC | SDL_INIT_AUDIO) < 0) {
    SDL_LogCritical("Unable to initialize SDL: %s", SDL_GetError());
    return EXIT_FAILURE;
  }

When I run under a debugger ‘SDL_GetError()’ does not return anything meaningful (actually nothing at all). The video and audio subsystems work fine when initialized together. It is the gamecontroller and haptic that cause it to fail. Suggestions?

EDIT:
I have tried compiling with microsoft libraries, i.e. cl.exe and associated headers:

cmake.exe -DCMAKE_BUILD_TYPE=Debug^
  -DVIDEO_OPENGL=ON -DDIRECTX=OFF -DRENDER_D3D=OFF -DVIDEO_DUMMY=OFF -DVIDEO_OPENGLES=OFF -DVIDEO_VULKAN=OFF^
  -DDISKAUDIO=OFF -DDUMMYAUDIO=OFF^
  -DSDL_STATIC=ON -DSDL_SHARED=OFF -DSDL_TEST=OFF ..
cmake.exe --build . 

I get a syntax error in SDL_joystick.c:


Subsequently I cannot build sdl2, only sdl2-main.

It seems that cl.exe does not support the C99 initialization here. So if this is the case, how has anyone compiled sdl2.0.9 for windows with working controller support??