From 8deb2cf0bbdc5e03609a24e382523df39db45844 Mon Sep 17 00:00:00 2001 From: Tomay Date: Thu, 10 Jan 2019 05:07:39 +0100 Subject: [PATCH] Add wxUSE_WINSOCK2 wxMSW option to include winsock2.h Including and is incompatible and if the application wants to use the latter, it may be convenient to define wxUSE_WINSOCK2 when building wxWidgets instead of having to work around winsock.h implicit inclusion from include/wx/msw/wrapwin.h. Closes https://github.com/wxWidgets/wxWidgets/pull/1122 --- build/cmake/options.cmake | 1 + build/cmake/setup.h.in | 2 ++ docs/doxygen/mainpages/const_wxusedef.h | 3 +++ include/wx/android/setup.h | 7 +++++++ include/wx/gtk/setup0.h | 7 +++++++ include/wx/msw/chkconf.h | 18 ++++++++++++++++++ include/wx/msw/setup0.h | 7 +++++++ include/wx/msw/setup_inc.h | 7 +++++++ include/wx/msw/wrapwin.h | 7 ++++--- include/wx/univ/setup0.h | 7 +++++++ setup.h.in | 2 ++ 11 files changed, 65 insertions(+), 3 deletions(-) diff --git a/build/cmake/options.cmake b/build/cmake/options.cmake index 3a2a13d42a..b7703811ac 100644 --- a/build/cmake/options.cmake +++ b/build/cmake/options.cmake @@ -174,6 +174,7 @@ if(WIN32) endif() wx_option(wxUSE_DBGHELP "use dbghelp.dll API" ${wxUSE_DBGHELP_DEFAULT}) wx_option(wxUSE_INICONF "use wxIniConfig") + wx_option(wxUSE_WINSOCK2 "include rather than " OFF) wx_option(wxUSE_REGKEY "use wxRegKey class") endif() diff --git a/build/cmake/setup.h.in b/build/cmake/setup.h.in index 8b3788591c..af4d7326d7 100644 --- a/build/cmake/setup.h.in +++ b/build/cmake/setup.h.in @@ -714,6 +714,8 @@ #cmakedefine01 wxUSE_INICONF +#cmakedefine01 wxUSE_WINSOCK2 + #cmakedefine01 wxUSE_DATEPICKCTRL_GENERIC diff --git a/docs/doxygen/mainpages/const_wxusedef.h b/docs/doxygen/mainpages/const_wxusedef.h index 9d52ed1821..12f1f9334d 100644 --- a/docs/doxygen/mainpages/const_wxusedef.h +++ b/docs/doxygen/mainpages/const_wxusedef.h @@ -348,6 +348,9 @@ compilers. See also wxUSE_NO_MANIFEST.} @itemdef{wxUSE_WIN_METAFILES_ALWAYS, Use wxMetaFile even when wxUSE_ENH_METAFILE=1.} @itemdef{wxUSE_WINRT, Enable WinRT support.} @itemdef{wxUSE_WXDIB, Use wxDIB class.} +@itemdef{wxUSE_WINSOCK2, Include @c instead of @c . +Turned on automatically if ::wxUSE_IPV6 is on (this option is new since +wxWidgets 3.1.3).} @endDefList diff --git a/include/wx/android/setup.h b/include/wx/android/setup.h index ccc99e7ad0..029987479f 100644 --- a/include/wx/android/setup.h +++ b/include/wx/android/setup.h @@ -1661,6 +1661,13 @@ // Recommended setting: 0, nobody uses .INI files any more #define wxUSE_INICONF 0 +// Set to 1 if you need to include over +// +// Default is 0. +// +// Recommended setting: 0 +#define wxUSE_WINSOCK2 0 + // ---------------------------------------------------------------------------- // Generic versions of native controls // ---------------------------------------------------------------------------- diff --git a/include/wx/gtk/setup0.h b/include/wx/gtk/setup0.h index 22ee07b8d0..c581562c6b 100644 --- a/include/wx/gtk/setup0.h +++ b/include/wx/gtk/setup0.h @@ -1713,6 +1713,13 @@ // Recommended setting: 0, nobody uses .INI files any more #define wxUSE_INICONF 0 +// Set to 1 if you need to include over +// +// Default is 0. +// +// Recommended setting: 0, set to 1 automatically if wxUSE_IPV6 is 1. +#define wxUSE_WINSOCK2 0 + // ---------------------------------------------------------------------------- // Generic versions of native controls // ---------------------------------------------------------------------------- diff --git a/include/wx/msw/chkconf.h b/include/wx/msw/chkconf.h index 4ef7be5d7f..6f9c161d37 100644 --- a/include/wx/msw/chkconf.h +++ b/include/wx/msw/chkconf.h @@ -118,6 +118,14 @@ # endif #endif /* wxUSE_UXTHEME */ +#ifndef wxUSE_WINSOCK2 +# ifdef wxABORT_ON_CONFIG_ERROR +# error "wxUSE_WINSOCK2 must be defined." +# else +# define wxUSE_WINSOCK2 0 +# endif +#endif /* wxUSE_WINSOCK2 */ + /* * Unfortunately we can't use compiler TLS support if the library can be used * inside a dynamically loaded DLL under Windows XP, as this can result in hard @@ -455,4 +463,14 @@ # define wxUSE_POSTSCRIPT 1 #endif +/* + IPv6 support requires winsock2.h, but the default of wxUSE_WINSOCK2 is 0. + Don't require changing it explicitly and just turn it on automatically if + wxUSE_IPV6 is on. + */ +#if wxUSE_IPV6 && !wxUSE_WINSOCK2 + #undef wxUSE_WINSOCK2 + #define wxUSE_WINSOCK2 1 +#endif + #endif /* _WX_MSW_CHKCONF_H_ */ diff --git a/include/wx/msw/setup0.h b/include/wx/msw/setup0.h index dcbb2d7fde..7b502ecbef 100644 --- a/include/wx/msw/setup0.h +++ b/include/wx/msw/setup0.h @@ -1713,6 +1713,13 @@ // Recommended setting: 0, nobody uses .INI files any more #define wxUSE_INICONF 0 +// Set to 1 if you need to include over +// +// Default is 0. +// +// Recommended setting: 0, set to 1 automatically if wxUSE_IPV6 is 1. +#define wxUSE_WINSOCK2 0 + // ---------------------------------------------------------------------------- // Generic versions of native controls // ---------------------------------------------------------------------------- diff --git a/include/wx/msw/setup_inc.h b/include/wx/msw/setup_inc.h index ff5fc00102..6a1ea9dbec 100644 --- a/include/wx/msw/setup_inc.h +++ b/include/wx/msw/setup_inc.h @@ -156,6 +156,13 @@ // Recommended setting: 0, nobody uses .INI files any more #define wxUSE_INICONF 0 +// Set to 1 if you need to include over +// +// Default is 0. +// +// Recommended setting: 0, set to 1 automatically if wxUSE_IPV6 is 1. +#define wxUSE_WINSOCK2 0 + // ---------------------------------------------------------------------------- // Generic versions of native controls // ---------------------------------------------------------------------------- diff --git a/include/wx/msw/wrapwin.h b/include/wx/msw/wrapwin.h index e4ef98a6b6..dbb3173af2 100644 --- a/include/wx/msw/wrapwin.h +++ b/include/wx/msw/wrapwin.h @@ -28,9 +28,10 @@ #endif // NOMINMAX -// For IPv6 support, we must include winsock2.h before winsock.h, and -// windows.h include winsock.h so do it before including it -#if wxUSE_IPV6 +// When the application wants to use (this is required for IPv6 +// support, for example), we must include it before winsock.h, and as windows.h +// includes winsock.h, we have to do it before including it. +#if wxUSE_WINSOCK2 #include #endif diff --git a/include/wx/univ/setup0.h b/include/wx/univ/setup0.h index 11c7277097..0ebca727fd 100644 --- a/include/wx/univ/setup0.h +++ b/include/wx/univ/setup0.h @@ -1661,6 +1661,13 @@ // Recommended setting: 0, nobody uses .INI files any more #define wxUSE_INICONF 0 +// Set to 1 if you need to include over +// +// Default is 0. +// +// Recommended setting: 0 +#define wxUSE_WINSOCK2 0 + // ---------------------------------------------------------------------------- // Generic versions of native controls // ---------------------------------------------------------------------------- diff --git a/setup.h.in b/setup.h.in index 9f703405c1..b33699b9c9 100644 --- a/setup.h.in +++ b/setup.h.in @@ -714,6 +714,8 @@ #define wxUSE_INICONF 0 +#define wxUSE_WINSOCK2 0 + #define wxUSE_DATEPICKCTRL_GENERIC 0