From bcf0fdd3a8ed46cce22527fc12d10160031e5373 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 19 May 2021 17:27:51 +0200 Subject: [PATCH] meson.build: define NOUSER on Windows for lighter windows.h A few exceptions are needed for sources which include COM header (directly or indirectly). This fixes lots of shadow warnings, see https://github.com/MusicPlayerDaemon/MPD/issues/1150 --- meson.build | 4 ++++ src/fs/Glob.cxx | 5 +++++ src/fs/StandardDirectory.cxx | 4 ++++ src/mixer/plugins/WasapiMixerPlugin.cxx | 2 ++ src/output/plugins/wasapi/WasapiOutputPlugin.cxx | 2 ++ src/win32/Com.hxx | 1 + src/win32/ComWorker.cxx | 2 ++ src/win32/HResult.cxx | 6 ++++++ src/win32/PropVariant.hxx | 1 + 9 files changed, 27 insertions(+) diff --git a/meson.build b/meson.build index 2bbb75255..14f67190a 100644 --- a/meson.build +++ b/meson.build @@ -156,6 +156,10 @@ if is_windows # disable more Windows APIs which are not used by MPD '-DNOGDI', '-DNOBITMAP', '-DNOCOMM', + '-DNOUSER', + + # reduce COM header bloat + '-DCOM_NO_WINDOWS_H', # disable Internet Explorer specific APIs '-D_WIN32_IE=0', diff --git a/src/fs/Glob.cxx b/src/fs/Glob.cxx index 4467853d0..f2119bd9a 100644 --- a/src/fs/Glob.cxx +++ b/src/fs/Glob.cxx @@ -17,6 +17,11 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#ifdef _WIN32 +// COM needs the "MSG" typedef, and shlwapi.h includes COM headers +#undef NOUSER +#endif + #include "Glob.hxx" #ifdef _WIN32 diff --git a/src/fs/StandardDirectory.cxx b/src/fs/StandardDirectory.cxx index 05bee122b..7190f7a95 100644 --- a/src/fs/StandardDirectory.cxx +++ b/src/fs/StandardDirectory.cxx @@ -17,6 +17,10 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#ifdef _WIN32 +#undef NOUSER // COM needs the "MSG" typedef, and shlobj.h includes COM headers +#endif + #include "StandardDirectory.hxx" #include "FileSystem.hxx" #include "XDG.hxx" diff --git a/src/mixer/plugins/WasapiMixerPlugin.cxx b/src/mixer/plugins/WasapiMixerPlugin.cxx index d0145405a..19bc11c08 100644 --- a/src/mixer/plugins/WasapiMixerPlugin.cxx +++ b/src/mixer/plugins/WasapiMixerPlugin.cxx @@ -17,6 +17,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#undef NOUSER // COM needs the "MSG" typedef + #include "output/plugins/wasapi/ForMixer.hxx" #include "output/plugins/wasapi/AudioClient.hxx" #include "output/plugins/wasapi/Device.hxx" diff --git a/src/output/plugins/wasapi/WasapiOutputPlugin.cxx b/src/output/plugins/wasapi/WasapiOutputPlugin.cxx index 86f7a21df..e331195e9 100644 --- a/src/output/plugins/wasapi/WasapiOutputPlugin.cxx +++ b/src/output/plugins/wasapi/WasapiOutputPlugin.cxx @@ -17,6 +17,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#undef NOUSER // COM needs the "MSG" typedef + #include "WasapiOutputPlugin.hxx" #include "ForMixer.hxx" #include "AudioClient.hxx" diff --git a/src/win32/Com.hxx b/src/win32/Com.hxx index a9e58761a..15b3b9d98 100644 --- a/src/win32/Com.hxx +++ b/src/win32/Com.hxx @@ -23,6 +23,7 @@ #include "HResult.hxx" #include +#include // for COINIT_APARTMENTTHREADED // RAII for Microsoft Component Object Model(COM) // https://docs.microsoft.com/en-us/windows/win32/api/_com/ diff --git a/src/win32/ComWorker.cxx b/src/win32/ComWorker.cxx index c5ada8c91..15150f76d 100644 --- a/src/win32/ComWorker.cxx +++ b/src/win32/ComWorker.cxx @@ -17,6 +17,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#undef NOUSER // COM needs the "MSG" typedef + #include "ComWorker.hxx" #include "Com.hxx" #include "thread/Name.hxx" diff --git a/src/win32/HResult.cxx b/src/win32/HResult.cxx index 89cca898b..a4e04caa6 100644 --- a/src/win32/HResult.cxx +++ b/src/win32/HResult.cxx @@ -17,6 +17,11 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#ifdef _WIN32 +// COM needs the "MSG" typedef, and audiopolicy.h includes COM headers +#undef NOUSER +#endif + #include "HResult.hxx" #include "system/Error.hxx" @@ -25,6 +30,7 @@ #include #include +#include // needed by audiopolicy.h if COM_NO_WINDOWS_H is defined #include std::string_view diff --git a/src/win32/PropVariant.hxx b/src/win32/PropVariant.hxx index 54da5e988..3f733441c 100644 --- a/src/win32/PropVariant.hxx +++ b/src/win32/PropVariant.hxx @@ -20,6 +20,7 @@ #ifndef MPD_WIN32_PROPVARIANT_HXX #define MPD_WIN32_PROPVARIANT_HXX +#include // needed by propidl.h if COM_NO_WINDOWS_H is defined #include class AllocatedString;