Cherry-picked from a14ff91254f40cf36e0fee199e26fb11260fab49. move _WIN32_WINNT defintions before first #include _WIN32_WINNT and WIN32_LEAN_AND_MEAN need to be defined before the windows.h is included for the first time. Avoid the confusion of indirect #include by defining before any. diff --git a/event_iocp.c b/event_iocp.c index 6b2a2e15..4955e426 100644 --- a/event_iocp.c +++ b/event_iocp.c @@ -23,12 +23,14 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "evconfig-private.h" #ifndef _WIN32_WINNT /* Minimum required for InitializeCriticalSectionAndSpinCount */ #define _WIN32_WINNT 0x0403 #endif + +#include "evconfig-private.h" + #include #include #include diff --git a/evthread_win32.c b/evthread_win32.c index 2ec80560..8647f72b 100644 --- a/evthread_win32.c +++ b/evthread_win32.c @@ -23,18 +23,21 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "event2/event-config.h" -#include "evconfig-private.h" #ifdef _WIN32 #ifndef _WIN32_WINNT /* Minimum required for InitializeCriticalSectionAndSpinCount */ #define _WIN32_WINNT 0x0403 #endif -#include #define WIN32_LEAN_AND_MEAN +#endif + +#include "event2/event-config.h" +#include "evconfig-private.h" + +#ifdef _WIN32 +#include #include -#undef WIN32_LEAN_AND_MEAN #include #endif diff --git a/evutil.c b/evutil.c index 9817f086..8537ffe8 100644 --- a/evutil.c +++ b/evutil.c @@ -24,6 +24,14 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#ifdef _WIN32 +#ifndef _WIN32_WINNT +/* For structs needed by GetAdaptersAddresses */ +#define _WIN32_WINNT 0x0501 +#endif +#define WIN32_LEAN_AND_MEAN +#endif + #include "event2/event-config.h" #include "evconfig-private.h" @@ -31,15 +39,10 @@ #include #include #include -#define WIN32_LEAN_AND_MEAN #include -#undef WIN32_LEAN_AND_MEAN #include #include #include -#undef _WIN32_WINNT -/* For structs needed by GetAdaptersAddresses */ -#define _WIN32_WINNT 0x0501 #include #include #endif diff --git a/listener.c b/listener.c index f5c00c9c..d1080e76 100644 --- a/listener.c +++ b/listener.c @@ -24,16 +24,19 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#ifdef _WIN32 +#ifndef _WIN32_WINNT +/* Minimum required for InitializeCriticalSectionAndSpinCount */ +#define _WIN32_WINNT 0x0403 +#endif +#endif + #include "event2/event-config.h" #include "evconfig-private.h" #include #ifdef _WIN32 -#ifndef _WIN32_WINNT -/* Minimum required for InitializeCriticalSectionAndSpinCount */ -#define _WIN32_WINNT 0x0403 -#endif #include #include #include