From af299f3c661dbc3f73b890ec5dfa9481a45271fd Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Tue, 11 May 2021 02:22:39 +0200 Subject: [PATCH] Always define NOMINMAX and friends globally Repeating this every time is worse than defining them in the compiler command line. --- meson.build | 39 ++++++++++++++++++------------------ src/wine-host/bridges/vst2.h | 5 ----- src/wine-host/editor.h | 5 ----- src/wine-host/utils.h | 6 ------ 4 files changed, 20 insertions(+), 35 deletions(-) diff --git a/meson.build b/meson.build index 71e1663c..d8cc4b50 100644 --- a/meson.build +++ b/meson.build @@ -48,11 +48,21 @@ compiler_options = [ '-msse2', ] +wine_compiler_options = [ + # Some stuff from `windows.h` results in conflicting definitions + '-DNOMINMAX', + # Winsock conflicts with the Posix sockets API. Before Wine 6.8 there was a + # `WINE_NOWINSOCK` that would exclude just `winsock.h` from `windows.h`, but + # they got rid of that so we now need to explicitly define the ifdef guards + '-D__WINE_WINSOCKAPI_STDLIB_H', + '-D_WINSOCKAPI_', +] + # NOTE: GCC doesn't 8-byte align doubles in structs on x86 for ABI-compatibilty # reasons, but MSVC++ does. We need to force this same alignment to be # ABI-compatible with 32-bit binaries created with MSVC++ on Windows. -wine_32bit_compiler_options = ['-m32', '-malign-double'] -wine_64bit_compiler_options = ['-m64'] +wine_32bit_compiler_options = wine_compiler_options + ['-m32', '-malign-double'] +wine_64bit_compiler_options = wine_compiler_options + ['-m64'] # Enable addition assertions on the STL containers during debug builds if get_option('buildtype') == 'debug' @@ -209,20 +219,11 @@ if with_vst3 error('Error while trying to patch the VST3 SDK:\n' + patch_result.stderr()) endif - vst3_wine_compiler_options = [ - # Some stuff from `windows.h` results in conflicting definitions - '-DNOMINMAX', - # Winsock conflicts with the Posix sockets API. Before Wine 6.8 there was a - # `WINE_NOWINSOCK` that would exclude just `winsock.h` from `windows.h`, but - # they got rid of that so we now need to explicitly define the ifdef guards - '-D__WINE_WINSOCKAPI_STDLIB_H', - '-D_WINSOCKAPI_', - ] vst3_base_wine_64bit = static_library( 'vst3_base_wine_64bit', vst3.get_variable('base_sources'), native : false, - cpp_args : vst3_compiler_options + vst3_wine_compiler_options + wine_64bit_compiler_options + [ '-Wno-cpp'], + cpp_args : vst3_compiler_options + wine_64bit_compiler_options + [ '-Wno-cpp'], include_directories : vst3_include_dir, override_options : ['warning_level=0'], ) @@ -230,7 +231,7 @@ if with_vst3 'vst3_pluginterfaces_wine_64bit', vst3.get_variable('pluginterfaces_sources'), native : false, - cpp_args : vst3_compiler_options + vst3_wine_compiler_options + wine_64bit_compiler_options, + cpp_args : vst3_compiler_options + wine_64bit_compiler_options, include_directories : vst3_include_dir, override_options : ['warning_level=0'], ) @@ -239,7 +240,7 @@ if with_vst3 vst3.get_variable('sdk_common_sources') + vst3.get_variable('sdk_hosting_sources'), native : false, link_with : [vst3_base_wine_64bit, vst3_pluginterfaces_wine_64bit], - cpp_args : vst3_compiler_options + vst3_wine_compiler_options + wine_64bit_compiler_options + ['-Wno-multichar'], + cpp_args : vst3_compiler_options + wine_64bit_compiler_options + ['-Wno-multichar'], include_directories : vst3_include_dir, override_options : ['warning_level=0'], ) @@ -249,7 +250,7 @@ if with_vst3 # This does mean that we now have a lot of defines in our code, but the # alternative would be patching every location in the SDK where they include # `windows.h` - compile_args : vst3_compiler_options + vst3_wine_compiler_options, + compile_args : vst3_compiler_options + wine_64bit_compiler_options, ) # And another time for the 32-bit version @@ -258,7 +259,7 @@ if with_vst3 'vst3_base_wine_32bit', vst3.get_variable('base_sources'), native : false, - cpp_args : vst3_compiler_options + vst3_wine_compiler_options + wine_32bit_compiler_options + ['-Wno-cpp'], + cpp_args : vst3_compiler_options + wine_32bit_compiler_options + ['-Wno-cpp'], include_directories : vst3_include_dir, override_options : ['warning_level=0'], ) @@ -266,7 +267,7 @@ if with_vst3 'vst3_pluginterfaces_wine_32bit', vst3.get_variable('pluginterfaces_sources'), native : false, - cpp_args : vst3_compiler_options + vst3_wine_compiler_options + wine_32bit_compiler_options, + cpp_args : vst3_compiler_options + wine_32bit_compiler_options, include_directories : vst3_include_dir, override_options : ['warning_level=0'], ) @@ -275,7 +276,7 @@ if with_vst3 vst3.get_variable('sdk_common_sources') + vst3.get_variable('sdk_hosting_sources'), native : false, link_with : [vst3_base_wine_32bit, vst3_pluginterfaces_wine_32bit], - cpp_args : vst3_compiler_options + vst3_wine_compiler_options + wine_32bit_compiler_options + ['-Wno-multichar'], + cpp_args : vst3_compiler_options + wine_32bit_compiler_options + ['-Wno-multichar'], include_directories : vst3_include_dir, override_options : ['warning_level=0'], ) @@ -285,7 +286,7 @@ if with_vst3 # This does mean that we now have a lot of defines in our code, but the # alternative would be patching every location in the SDK where they include # `windows.h` - compile_args : vst3_compiler_options + vst3_wine_compiler_options, + compile_args : vst3_compiler_options + wine_32bit_compiler_options, ) endif endif diff --git a/src/wine-host/bridges/vst2.h b/src/wine-host/bridges/vst2.h index f5d5331e..c8fcb8c9 100644 --- a/src/wine-host/bridges/vst2.h +++ b/src/wine-host/bridges/vst2.h @@ -18,11 +18,6 @@ #include "../boost-fix.h" -#ifndef NOMINMAX -#define NOMINMAX -#define __WINE_WINSOCKAPI_STDLIB_H -#define _WINSOCKAPI_ -#endif #include #include diff --git a/src/wine-host/editor.h b/src/wine-host/editor.h index 8a23875b..56532b65 100644 --- a/src/wine-host/editor.h +++ b/src/wine-host/editor.h @@ -20,11 +20,6 @@ #include #include -#ifndef NOMINMAX -#define NOMINMAX -#define __WINE_WINSOCKAPI_STDLIB_H -#define _WINSOCKAPI_ -#endif #include #include diff --git a/src/wine-host/utils.h b/src/wine-host/utils.h index 9de31ed9..fbb58c47 100644 --- a/src/wine-host/utils.h +++ b/src/wine-host/utils.h @@ -23,13 +23,7 @@ #include #include -#ifndef NOMINMAX -#define NOMINMAX -#define __WINE_WINSOCKAPI_STDLIB_H -#define _WINSOCKAPI_ -#endif #include - #include #include #include