[PATCH 07 of 11] Win32: improved MinGW/MinGW-w64 GCC checks
Maxim Dounin
mdounin at mdounin.ru
Wed Aug 7 01:03:52 UTC 2024
# HG changeset patch
# User Maxim Dounin <mdounin at mdounin.ru>
# Date 1722992219 -10800
# Wed Aug 07 03:56:59 2024 +0300
# 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 --git a/src/os/win32/ngx_atomic.h b/src/os/win32/ngx_atomic.h
--- 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 */
diff --git a/src/os/win32/ngx_win32_config.h b/src/os/win32/ngx_win32_config.h
--- 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
More information about the nginx-devel
mailing list