# HG changeset patch # User Maxim Dounin # Date 1722992219 -10800 # Node ID 32a5186a27058925bfa9280215ecee114a56d6be # Parent 7c350e5171682e6fb079408c4f3258074d973df6 Win32: improved MinGW/MinGW-w64 GCC checks. Previously, __GNUC__ was checked, which is now replaced with __MINGW32__ checks. The difference is that __MINGW32__ is defined when using MinGW (or MinGW-w64) header files regardless of the compiler being used. And, more importantly, it is not defined when Clang is being used (which pretends to be GCC by default) with Windows SDK header files. With this change, it is now possible to compile nginx with native Clang on Windows. This current requires --with-ld-opt="-lkernel32 -luser32" though, since native Clang on Windows uses MSVC linker, which does not link kernel32.lib and user32.lib automatically. diff -r 7c350e517168 -r 32a5186a2705 src/os/win32/ngx_atomic.h --- a/src/os/win32/ngx_atomic.h Wed Aug 07 03:56:49 2024 +0300 +++ b/src/os/win32/ngx_atomic.h Wed Aug 07 03:56:59 2024 +0300 @@ -21,7 +21,7 @@ #define NGX_ATOMIC_T_LEN (sizeof("-2147483648") - 1) -#if defined( __WATCOMC__ ) || defined( __BORLANDC__ ) || defined(__GNUC__) \ +#if defined( __WATCOMC__ ) || defined( __BORLANDC__ ) || defined(__MINGW32__) \ || ( _MSC_VER >= 1300 ) /* the new SDK headers */ diff -r 7c350e517168 -r 32a5186a2705 src/os/win32/ngx_win32_config.h --- a/src/os/win32/ngx_win32_config.h Wed Aug 07 03:56:49 2024 +0300 +++ b/src/os/win32/ngx_win32_config.h Wed Aug 07 03:56:59 2024 +0300 @@ -47,7 +47,7 @@ /* GCC MinGW-w64 supports _FILE_OFFSET_BITS */ #define _FILE_OFFSET_BITS 64 -#elif defined __GNUC__ +#elif defined __MINGW32__ /* GCC MinGW's stdio.h includes sys/types.h */ #define _OFF_T_ @@ -58,7 +58,7 @@ #include #include #include -#ifdef __GNUC__ +#ifdef __MINGW32__ #include #endif #include @@ -198,7 +198,7 @@ #endif -#ifndef __GNUC__ +#ifndef __MINGW32__ #ifdef _WIN64 typedef __int64 ssize_t; #else