From ed107c4116c246acad2afba3b93e0e0d8d4a8d4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= Date: Fri, 24 Nov 2023 07:19:19 +0100 Subject: [PATCH] meson: adjust win32 defines - Don't define _GNU_SOURCE on Windows, no need - Define WIN32_LEAN_AND_MEAN to strip some unneded headers from windows.h - Define NOMINMAX and _USE_MATH_DEFINES as they are common for Windows headers --- audio/out/ao_wasapi_utils.c | 1 + meson.build | 11 ++++++++--- osdep/main-fn-win.c | 1 + stream/stream_file.c | 1 + video/out/win32/droptarget.c | 1 + 5 files changed, 12 insertions(+), 3 deletions(-) diff --git a/audio/out/ao_wasapi_utils.c b/audio/out/ao_wasapi_utils.c index 731fe8a85e..c6f66d9371 100644 --- a/audio/out/ao_wasapi_utils.c +++ b/audio/out/ao_wasapi_utils.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include diff --git a/meson.build b/meson.build index 51ff910a9f..86b8de77ad 100644 --- a/meson.build +++ b/meson.build @@ -260,7 +260,7 @@ sources = files( # compiler stuff cc = meson.get_compiler('c') -flags = ['-D_GNU_SOURCE', '-D_FILE_OFFSET_BITS=64'] +flags = ['-D_FILE_OFFSET_BITS=64'] link_flags = [] test_flags = ['-Werror=implicit-function-declaration', @@ -304,8 +304,9 @@ features += {'darwin': darwin} features += {'posix': posix} features += {'dos-paths': win32, 'win32': win32} -mswin_flags = ['-D_WIN32_WINNT=0x0602', '-DUNICODE', '-DCOBJMACROS', - '-DINITGUID', '-U__STRICT_ANSI__'] +mswin_flags = ['-D_WIN32_WINNT=0x0602', '-DWINVER=0x0602', '-DUNICODE', + '-DCOBJMACROS', '-DINITGUID', '-U__STRICT_ANSI__', '-DNOMINMAX', + '-D_USE_MATH_DEFINES', '-DWIN32_LEAN_AND_MEAN'] if host_machine.system() == 'windows' flags += [mswin_flags] @@ -315,6 +316,10 @@ if host_machine.system() == 'cygwin' flags += [mswin_flags, '-mwin32'] endif +if posix + flags += ['-D_GNU_SOURCE'] +endif + noexecstack = false if cc.has_link_argument('-Wl,-z,noexecstack') link_flags += '-Wl,-z,noexecstack' diff --git a/osdep/main-fn-win.c b/osdep/main-fn-win.c index 16ea80bc7f..dfccb4c910 100644 --- a/osdep/main-fn-win.c +++ b/osdep/main-fn-win.c @@ -1,4 +1,5 @@ #include +#include #ifndef BASE_SEARCH_PATH_ENABLE_SAFE_SEARCHMODE #define BASE_SEARCH_PATH_ENABLE_SAFE_SEARCHMODE (0x0001) diff --git a/stream/stream_file.c b/stream/stream_file.c index 4895a8301b..5f06131f18 100644 --- a/stream/stream_file.c +++ b/stream/stream_file.c @@ -50,6 +50,7 @@ #ifdef _WIN32 #include +#include #include #include diff --git a/video/out/win32/droptarget.c b/video/out/win32/droptarget.c index 8a33522df0..b1b4824d9c 100644 --- a/video/out/win32/droptarget.c +++ b/video/out/win32/droptarget.c @@ -18,6 +18,7 @@ #include #include +#include #include #include "common/msg.h"