Fixed bug 4450 - SDL_mouse.c fails to compile with CMake generated Visual Studio files if SDL_VIDEO_VULKAN 0/undefined
authorSam Lantinga <slouken@libsdl.org>
Sat, 16 Mar 2019 19:07:34 -0700
changeset 12651d188272453ce
parent 12650 7c94bfe06b4a
child 12652 b3c652757f97
Fixed bug 4450 - SDL_mouse.c fails to compile with CMake generated Visual Studio files if SDL_VIDEO_VULKAN 0/undefined

Max Waine

SDL_mouse.c, if compiled for Windows, requires GetDoubleClickTime to compile (available from winuser.h). Without Vulkan present this fails to compile as the include chain for winuser.h is the following.

SDL_mouse.c -> SDL_sysvideo.h -> SDL_vulkan_internal.h -> SDL_windows.h -> windows.h -> winuser.h.
Problem is that SDL_vulkan_internal.h doesn't include SDL_windows.h if Vulkan isn't present, so under MinGW/GCC it will give a -Wimplicit-function-declaration warning for GetDoubleClickTime, and under MSVC fails to compile completely.

The solution to this would be to simplify the include chain: including SDL_windows.h under the same condition as GetDoubleClickTime (#ifdef __WIN32__) in SDL_mouse.c (or another file that isn't quite so indirectly included).
src/events/SDL_mouse.c
     1.1 --- a/src/events/SDL_mouse.c	Sat Mar 16 19:03:13 2019 -0700
     1.2 +++ b/src/events/SDL_mouse.c	Sat Mar 16 19:07:34 2019 -0700
     1.3 @@ -28,6 +28,9 @@
     1.4  #include "SDL_events.h"
     1.5  #include "SDL_events_c.h"
     1.6  #include "../video/SDL_sysvideo.h"
     1.7 +#ifdef __WIN32__
     1.8 +#include "../core/windows/SDL_windows.h"    // For GetDoubleClickTime()
     1.9 +#endif
    1.10  
    1.11  /* #define DEBUG_MOUSE */
    1.12