From e215682be2fb05fb579edf3a1c2f99fa85ee88a8 Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Mon, 29 Jun 2020 01:03:11 +0200 Subject: [PATCH] win: use lower case file names when importing Windows SDK headers Although the header files included in the official Windows SDK have mixed case file names, MinGW opted to ship headers with entirely lower case names. Since the MinGW headers are often used when cross compiling Windows binaries on Linux hosts, and Linux treats paths as case sensitive by default, following the 'official' spelling breaks many cross build setups. Non-cross builds do not seem to be affected by using lower case file names, and Microsoft also does not seem particularly consistent in the way it spells header file names in e.g. documentation and sample code. Therefore, this patch makes wepoll use lower case file names when including Windows headers, regardless of whether MinGW or the official SDK is used. See also https://github.com/libevent/libevent/pull/1039 and https://github.com/stjepang/smol/issues/138. Closes: https://github.com/piscisaureus/wepoll/pull/19 --- src/win.h | 39 +++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/src/win.h b/src/win.h index 0c3a223..ee01304 100644 --- a/src/win.h +++ b/src/win.h @@ -1,34 +1,29 @@ #ifndef WEPOLL_WIN_H_ #define WEPOLL_WIN_H_ -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN -#endif - -#ifdef __clang__ +#if defined(__clang__) #pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wnonportable-system-include-path" #pragma clang diagnostic ignored "-Wreserved-id-macro" -#endif - -#ifdef _WIN32_WINNT -#undef _WIN32_WINNT -#endif - -#define _WIN32_WINNT 0x0600 - -#ifdef __clang__ -#pragma clang diagnostic pop -#endif - -#ifndef __GNUC__ +#elif defined(_MSC_VER) #pragma warning(push, 1) #endif -#include -#include -#include +#undef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN -#ifndef __GNUC__ +#undef _WIN32_WINNT +#define _WIN32_WINNT 0x0600 + +/* clang-format off */ +#include +#include +#include +/* clang-format on */ + +#if defined(__clang__) +#pragma clang diagnostic pop +#elif defined(_MSC_VER) #pragma warning(pop) #endif