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 <kwiberg@webrtc.org>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#21840}
diff --git a/examples/peerconnection/client/main_wnd.h b/examples/peerconnection/client/main_wnd.h
index f3ed2f5..8edf81f 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 cf9eab6..5bc3f46 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 42a7fd6..a31680d 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 7f62bcc..ca5984a 100644
--- a/rtc_base/openssladapter.cc
+++ b/rtc_base/openssladapter.cc
@@ -14,8 +14,10 @@
#include <unistd.h>
#endif
+#if defined(WEBRTC_WIN)
// Must be included first before openssl headers.
#include "rtc_base/win32.h" // NOLINT
+#endif // WEBRTC_WIN
#include <openssl/bio.h>
#include <openssl/crypto.h>
diff --git a/rtc_base/opensslidentity.cc b/rtc_base/opensslidentity.cc
index 726ae3b..477a0e6 100644
--- a/rtc_base/opensslidentity.cc
+++ b/rtc_base/opensslidentity.cc
@@ -12,8 +12,10 @@
#include <memory>
+#if defined(WEBRTC_WIN)
// Must be included first before openssl headers.
#include "rtc_base/win32.h" // NOLINT
+#endif // WEBRTC_WIN
#include <openssl/bio.h>
#include <openssl/bn.h>
diff --git a/rtc_base/win32.h b/rtc_base/win32.h
index 0cbc412..78f66a7 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 @@
} // namespace rtc
-#endif // WEBRTC_WIN
#endif // RTC_BASE_WIN32_H_