Trying to compile this snippet
#define _WIN32_WINNT 0x0600
will cause a compilation failure because some declarations depending on wingdi.h data structures are being defined. In particular CreateDesktopExA depends on DEVMODE.
The attached patch fixes that.
I found this issue while trying to build Mesa3D with mingw-w64.