[nginx] Win32: improved MinGW/MinGW-w64 GCC checks.
Maxim Dounin
mdounin at mdounin.ru
Mon Aug 12 03:37:05 UTC 2024
details: http://freenginx.org/hg/nginx/rev/32a5186a2705
branches:
changeset: 9314:32a5186a2705
user: Maxim Dounin <mdounin at mdounin.ru>
date: Wed Aug 07 03:56:59 2024 +0300
description:
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.
diffstat:
src/os/win32/ngx_atomic.h | 2 +-
src/os/win32/ngx_win32_config.h | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
diffs (42 lines):
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