From e062385dc7a75bd8b91a5592fd862b2ad5ce760e Mon Sep 17 00:00:00 2001 From: Mirko Bonadei Date: Thu, 1 Feb 2018 11:17:40 +0100 Subject: [PATCH] Avoid to unconditionally include rtc_base/win32.h. This CL adds #error to spot where rtc_base/win32.h is unconditionally included and fixes all the places where it happens. Bug: webrtc:8814 Change-Id: I3c005acf2cdb58a51f1bcaa4acaeebd272c56660 Reviewed-on: https://webrtc-review.googlesource.com/46060 Reviewed-by: Karl Wiberg Commit-Queue: Mirko Bonadei Cr-Commit-Position: refs/heads/master@{#21840} --- examples/peerconnection/client/main_wnd.h | 2 ++ media/engine/webrtcvideocapturer.cc | 3 +++ rtc_base/ipaddress.cc | 3 +++ rtc_base/openssladapter.cc | 2 ++ rtc_base/opensslidentity.cc | 2 ++ rtc_base/win32.h | 5 +++-- 6 files changed, 15 insertions(+), 2 deletions(-) diff --git a/examples/peerconnection/client/main_wnd.h b/examples/peerconnection/client/main_wnd.h index f3ed2f576c..8edf81ffb3 100644 --- a/examples/peerconnection/client/main_wnd.h +++ b/examples/peerconnection/client/main_wnd.h @@ -20,7 +20,9 @@ #include "examples/peerconnection/client/peer_connection_client.h" #include "media/base/mediachannel.h" #include "media/base/videocommon.h" +#if defined(WEBRTC_WIN) #include "rtc_base/win32.h" +#endif // WEBRTC_WIN class MainWndCallback { public: diff --git a/media/engine/webrtcvideocapturer.cc b/media/engine/webrtcvideocapturer.cc index cf9eab6e6c..5bc3f46093 100644 --- a/media/engine/webrtcvideocapturer.cc +++ b/media/engine/webrtcvideocapturer.cc @@ -20,7 +20,10 @@ #include "rtc_base/timeutils.h" #include "modules/video_capture/video_capture_factory.h" + +#if defined(WEBRTC_WIN) #include "rtc_base/win32.h" // Need this to #include the impl files. +#endif // WEBRTC_WIN #include "system_wrappers/include/field_trial.h" namespace cricket { diff --git a/rtc_base/ipaddress.cc b/rtc_base/ipaddress.cc index 42a7fd6811..a31680d851 100644 --- a/rtc_base/ipaddress.cc +++ b/rtc_base/ipaddress.cc @@ -31,7 +31,10 @@ #include "rtc_base/logging.h" #include "rtc_base/nethelpers.h" #include "rtc_base/stringutils.h" + +#if defined(WEBRTC_WIN) #include "rtc_base/win32.h" +#endif // WEBRTC_WIN namespace rtc { diff --git a/rtc_base/openssladapter.cc b/rtc_base/openssladapter.cc index 7f62bcc5ec..ca5984a84a 100644 --- a/rtc_base/openssladapter.cc +++ b/rtc_base/openssladapter.cc @@ -14,8 +14,10 @@ #include #endif +#if defined(WEBRTC_WIN) // Must be included first before openssl headers. #include "rtc_base/win32.h" // NOLINT +#endif // WEBRTC_WIN #include #include diff --git a/rtc_base/opensslidentity.cc b/rtc_base/opensslidentity.cc index 726ae3b99c..477a0e61f7 100644 --- a/rtc_base/opensslidentity.cc +++ b/rtc_base/opensslidentity.cc @@ -12,8 +12,10 @@ #include +#if defined(WEBRTC_WIN) // Must be included first before openssl headers. #include "rtc_base/win32.h" // NOLINT +#endif // WEBRTC_WIN #include #include diff --git a/rtc_base/win32.h b/rtc_base/win32.h index 0cbc412c0a..78f66a77de 100644 --- a/rtc_base/win32.h +++ b/rtc_base/win32.h @@ -11,7 +11,9 @@ #ifndef RTC_BASE_WIN32_H_ #define RTC_BASE_WIN32_H_ -#if defined(WEBRTC_WIN) +#ifndef WEBRTC_WIN +#error "Only #include this header in Windows builds" +#endif #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN @@ -83,5 +85,4 @@ inline bool IsCurrentProcessLowIntegrity() { } // namespace rtc -#endif // WEBRTC_WIN #endif // RTC_BASE_WIN32_H_