Fix latest MinGW build error (S_OK, __FD_ISSET, STR #3454).
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@12679 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
6e5c31eab6
commit
67fd2793a3
2
CHANGES
2
CHANGES
@ -3,6 +3,8 @@ CHANGES IN FLTK 1.3.5 RELEASED: ??? ?? 2017
|
||||
|
||||
Bug fixes and other improvements
|
||||
|
||||
- Fix a MinGW build error with new MinGW versions as of Feb 2018
|
||||
(undefined S_OK and __FD_ISSET), see STR #3454.
|
||||
- Windows/CMake: Add missing definition of WIN32 for Windows builds.
|
||||
This seems to be necessary for VS2017 and other compilers that
|
||||
don't #define WIN32, but FLTK relies on this preprocessor macro.
|
||||
|
18
src/Fl.cxx
18
src/Fl.cxx
@ -3,7 +3,7 @@
|
||||
//
|
||||
// Main event handling code for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2015 by Bill Spitzak and others.
|
||||
// Copyright 1998-2018 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
@ -39,8 +39,24 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
// STR #3454: We must #define FD_ISSET before we #include winsock2.h
|
||||
// to fix an undefined reference (__FD_ISSET). (AlbrechtS Feb 2018)
|
||||
// Other portions of the fix for STR #3454 are in src/Fl_win32.cxx.
|
||||
// This fix is only necessary for MinGW.
|
||||
|
||||
#ifdef __MINGW32__
|
||||
static void * get_wsock_mod();
|
||||
typedef int(__stdcall *fl_wsk_fd_is_set_f)(unsigned int, void *);
|
||||
static fl_wsk_fd_is_set_f fl_wsk_fd_is_set = 0;
|
||||
|
||||
#define FD_ISSET(S,SET) \
|
||||
(get_wsock_mod() ? fl_wsk_fd_is_set(S, SET) : 0)
|
||||
#endif // __MINGW32__
|
||||
|
||||
// recent versions of MinGW warn: "Please include winsock2.h before windows.h",
|
||||
// hence we must include winsock2.h before FL/Fl.H (A.S. Dec. 2010, IMM May 2011)
|
||||
|
||||
#if defined(WIN32) && !defined(__CYGWIN__)
|
||||
# include <winsock2.h>
|
||||
#endif
|
||||
|
@ -3,7 +3,7 @@
|
||||
//
|
||||
// WIN32-specific code for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2016 by Bill Spitzak and others.
|
||||
// Copyright 1998-2018 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
@ -60,6 +60,11 @@
|
||||
#include <ole2.h>
|
||||
#include <shellapi.h>
|
||||
|
||||
// New versions of MinGW (as of Feb 2018) need to include winerror.h to
|
||||
// #define S_OK which used to be defined in ole2.h (STR #3454)
|
||||
|
||||
#include <winerror.h>
|
||||
|
||||
//
|
||||
// USE_ASYNC_SELECT - define it if you have WSAAsyncSelect()...
|
||||
// USE_ASYNC_SELECT is OBSOLETED in 1.3 for the following reasons:
|
||||
@ -100,14 +105,24 @@ static bool initial_clipboard = true;
|
||||
// note: winsock2.h has been #include'd in Fl.cxx
|
||||
#define WSCK_DLL_NAME "WS2_32.DLL"
|
||||
|
||||
// Patch for MinGW (__MINGW32__): see STR #3454 and src/Fl.cxx
|
||||
#ifdef __MINGW32__
|
||||
typedef int(WINAPI *fl_wsk_fd_is_set_f)(unsigned int, void *);
|
||||
#else
|
||||
typedef int(WINAPI *fl_wsk_fd_is_set_f)(SOCKET, fd_set *);
|
||||
static fl_wsk_fd_is_set_f fl_wsk_fd_is_set = 0;
|
||||
#endif
|
||||
|
||||
typedef int (WINAPI* fl_wsk_select_f)(int, fd_set*, fd_set*, fd_set*, const struct timeval*);
|
||||
typedef int (WINAPI* fl_wsk_fd_is_set_f)(SOCKET, fd_set *);
|
||||
|
||||
static HMODULE s_wsock_mod = 0;
|
||||
static fl_wsk_select_f s_wsock_select = 0;
|
||||
static fl_wsk_fd_is_set_f fl_wsk_fd_is_set = 0;
|
||||
|
||||
#ifdef __MINGW32__
|
||||
static void * get_wsock_mod() {
|
||||
#else
|
||||
static HMODULE get_wsock_mod() {
|
||||
#endif
|
||||
if (!s_wsock_mod) {
|
||||
s_wsock_mod = LoadLibrary(WSCK_DLL_NAME);
|
||||
if (s_wsock_mod==NULL)
|
||||
|
Loading…
x
Reference in New Issue
Block a user