On the Windows SDK, the definition of DllMain is hardcoded to using
unsigned long as reason parameter.
MinGW has two definitions and the definition of DllMain is different in
MinGW given `_WINDOWS_` is defined or not, leading to a different
prototype between VLC and process.h currently (not taking the `_WINDOWS_`
path):
../subprojects/vlc/src/win32/thread.c:688:15: error: conflicting types for 'DllMain'; have 'int(void *, long unsigned int, void *)'
688 | int __stdcall DllMain (void *hinstDll, unsigned long fdwReason, void *lpvReserved)
| ^~~~~~~
In file included from ../subprojects/vlc/src/win32/thread.c:33:
/usr/share/mingw-w64/include/process.h:141:17: note: previous declaration of 'DllMain' with type 'int(void *, unsigned int, void *)'
141 | int __stdcall DllMain(void *_HDllHandle,unsigned _Reason,void *_Reserved);
This was fixed VLC upstream and for newer mingw64 revision with the
[MR !4300] but even though the Windows SDK uses unsigned long, the
documentation[^1] uses DWORD which matches how mingw64 writes the
prototype. By doing the change, we can support older Mingw SDKs (using
the proper definition path) and yet-to-be-released SDKs (where the
definition would use something else than unsigned long).
[MR !4300]: https://code.videolan.org/videolan/vlc/-/merge_requests/4300
[^1]: https://learn.microsoft.com/en-us/windows/win32/dlls/dllmain
So as to use DWORD, we must include <windows.h> first as noted by commit
9ca790a641 that we're essentially
partially reverting here.
After this change, this would work regardless of the SDK vendor or the
SDK version.