adb / libbase: clean up NOGDI and evil ERROR macro
Instead of defining and undefining NOGDI:
1. Always #include "base/logging.h" after #include <windows.h>.
Unfortunately, I could not find an easy way to give the user a
warning/error if they include in the wrong order.
2. base/logging.h does #undef ERROR to undefine the evil ERROR macro
that is from another era and probably a bad idea to begin with.
Change-Id: I995d89620611e849af9d7ec47eb55fc0512377f2
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
diff --git a/base/include/base/logging.h b/base/include/base/logging.h
index 4a15f43..283a7bc 100644
--- a/base/include/base/logging.h
+++ b/base/include/base/logging.h
@@ -13,18 +13,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
#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
-
+// NOTE: For Windows, you must include logging.h after windows.h to allow the
+// following code to suppress the evil ERROR macro:
#ifdef _WIN32
-#ifndef NOGDI
-#define NOGDI // Suppress the evil ERROR macro.
+// windows.h includes wingdi.h which defines an evil macro ERROR.
+#ifdef ERROR
+#undef ERROR
#endif
#endif
diff --git a/base/logging.cpp b/base/logging.cpp
index 7a08c39..34229a2 100644
--- a/base/logging.cpp
+++ b/base/logging.cpp
@@ -14,6 +14,10 @@
* limitations under the License.
*/
+#ifdef _WIN32
+#include <windows.h>
+#endif
+
#include "base/logging.h"
#include <libgen.h>
@@ -34,8 +38,6 @@
#ifndef _WIN32
#include <mutex>
-#else
-#include <windows.h>
#endif
#include "base/macros.h"