changeset 9314:32a5186a2705

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.
author Maxim Dounin <mdounin@mdounin.ru>
date Wed, 07 Aug 2024 03:56:59 +0300
parents 7c350e517168
children d286426eab1a
files src/os/win32/ngx_atomic.h src/os/win32/ngx_win32_config.h
diffstat 2 files changed, 4 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/os/win32/ngx_atomic.h
+++ b/src/os/win32/ngx_atomic.h
@@ -21,7 +21,7 @@ typedef volatile ngx_atomic_uint_t  ngx_
 #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 */
--- a/src/os/win32/ngx_win32_config.h
+++ b/src/os/win32/ngx_win32_config.h
@@ -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 <stdio.h>
 #include <stdlib.h>
 #include <stdarg.h>
-#ifdef __GNUC__
+#ifdef __MINGW32__
 #include <stdint.h>
 #endif
 #include <ctype.h>
@@ -198,7 +198,7 @@ typedef unsigned int        ino_t;
 #endif
 
 
-#ifndef __GNUC__
+#ifndef __MINGW32__
 #ifdef _WIN64
 typedef __int64             ssize_t;
 #else