From 126d0b932fb8fb034d6f4dc4487f222e7a5ee801 Mon Sep 17 00:00:00 2001 From: Bruce Dawson Date: Sun, 29 Aug 2021 10:04:02 -0700 Subject: [PATCH] Avoid windows.h in shared_memory.h shared_memory.h ends up being included by consumers of webrtc such as Chromium so it causes namespace pollution. Specifically, it causes SendMessageCallback to be defined as SendMessageCallbackW partway through compilation of security_key_auth_handler_win_unittest.cc, leading to renaming of SendMessageCallback when it is used but not when it is defined. Bug: Chromium:796644 Change-Id: Ib1acc0d736a0a6cf97e318e773b20d9a432f6b77 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/229901 Commit-Queue: Bruce Dawson Reviewed-by: Joe Downing Cr-Commit-Position: refs/heads/main@{#34887} --- modules/desktop_capture/shared_memory.h | 4 +++- modules/desktop_capture/win/screen_capture_utils.h | 10 ++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/modules/desktop_capture/shared_memory.h b/modules/desktop_capture/shared_memory.h index 2e2d2f3388..49a9252c1b 100644 --- a/modules/desktop_capture/shared_memory.h +++ b/modules/desktop_capture/shared_memory.h @@ -14,7 +14,9 @@ #include #if defined(WEBRTC_WIN) -#include +// Forward declare HANDLE in a windows.h compatible way so that we can avoid +// including windows.h. +typedef void* HANDLE; #endif #include diff --git a/modules/desktop_capture/win/screen_capture_utils.h b/modules/desktop_capture/win/screen_capture_utils.h index 1e0541b5b8..ac60c5abc5 100644 --- a/modules/desktop_capture/win/screen_capture_utils.h +++ b/modules/desktop_capture/win/screen_capture_utils.h @@ -11,6 +11,16 @@ #ifndef MODULES_DESKTOP_CAPTURE_WIN_SCREEN_CAPTURE_UTILS_H_ #define MODULES_DESKTOP_CAPTURE_WIN_SCREEN_CAPTURE_UTILS_H_ +#if defined(WEBRTC_WIN) +// Forward declare HMONITOR in a windows.h compatible way so that we can avoid +// including windows.h. +#define WEBRTC_DECLARE_HANDLE(name) \ +struct name##__; \ +typedef struct name##__* name +WEBRTC_DECLARE_HANDLE(HMONITOR); +#undef WEBRTC_DECLARE_HANDLE +#endif + #include #include