summaryrefslogtreecommitdiff
path: root/base
diff options
context:
space:
mode:
authorDan Albert <danalbert@google.com>2015-05-04 16:40:38 -0700
committerDan Albert <danalbert@google.com>2015-05-04 16:40:38 -0700
commitea41c213bea5dcc04dea39a2903dc7f301bd5184 (patch)
tree07417c133a35dd5e05abccf606293643013139b4 /base
parent14799c624985839ef587560d61c67a3565fcac2b (diff)
Add additional shielding against the ERROR macro.
Including the logging header with ERROR defined will always be a problem, so check for it explicitly. Move the NOGDI define from logging.cpp to logging.h since the standard library headers might be including windows.h, pulling in ERROR. Change-Id: Ib426973d2f1840710c0bf0e0cfb2420d0d322e27
Diffstat (limited to 'base')
-rw-r--r--base/include/base/logging.h9
-rw-r--r--base/logging.cpp1
2 files changed, 9 insertions, 1 deletions
diff --git a/base/include/base/logging.h b/base/include/base/logging.h
index 230adb8b0..84ec538a2 100644
--- a/base/include/base/logging.h
+++ b/base/include/base/logging.h
@@ -17,6 +17,15 @@
#ifndef BASE_LOGGING_H
#define BASE_LOGGING_H
+#ifdef ERROR
+#error ERROR is already defined. If this is Windows code, #define NOGDI before \
+including anything.
+#endif
+
+#ifdef _WIN32
+#define NOGDI // Suppress the evil ERROR macro.
+#endif
+
#include <functional>
#include <memory>
#include <ostream>
diff --git a/base/logging.cpp b/base/logging.cpp
index 83957b38d..7a08c39f2 100644
--- a/base/logging.cpp
+++ b/base/logging.cpp
@@ -35,7 +35,6 @@
#ifndef _WIN32
#include <mutex>
#else
-#define NOGDI // Suppress the evil ERROR macro.
#include <windows.h>
#endif