From 99b015430f4bfe42a6d116d42c638523752eeb18 Mon Sep 17 00:00:00 2001 From: Laszlo Csomor Date: Thu, 2 Mar 2017 11:43:21 +0000 Subject: Bazel client: fix broken compilation Do not include in file_platform.h because it #defines many symbols that later code, particularly function definitions, conflict with, e.g. GetUserName, SendMessage. This was breaking the Bazel bootstrap project on CI. -- Change-Id: Ie4b59b00fc617bd3e7d0cbb967c1232798e055de Reviewed-on: https://cr.bazel.build/9127 PiperOrigin-RevId: 148986922 MOS_MIGRATED_REVID=148986922 --- src/main/cpp/blaze_util_windows.cc | 6 ++++++ src/main/cpp/util/file_platform.h | 15 +++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/main/cpp/blaze_util_windows.cc b/src/main/cpp/blaze_util_windows.cc index 839490b48e..a862fdaea6 100644 --- a/src/main/cpp/blaze_util_windows.cc +++ b/src/main/cpp/blaze_util_windows.cc @@ -1274,6 +1274,12 @@ void ReleaseLock(BlazeLock* blaze_lock) { #endif // COMPILER_MSVC } +#ifdef GetUserName +// By including , we have GetUserName defined either as +// GetUserNameA or GetUserNameW. +#undef GetUserName +#endif + string GetUserName() { WCHAR buffer[UNLEN + 1]; DWORD len = UNLEN + 1; diff --git a/src/main/cpp/util/file_platform.h b/src/main/cpp/util/file_platform.h index d8b254ecf4..02f5b8725b 100644 --- a/src/main/cpp/util/file_platform.h +++ b/src/main/cpp/util/file_platform.h @@ -15,13 +15,6 @@ #ifndef BAZEL_SRC_MAIN_CPP_UTIL_FILE_PLATFORM_H_ #define BAZEL_SRC_MAIN_CPP_UTIL_FILE_PLATFORM_H_ -#if defined(COMPILER_MSVC) || defined(__CYGWIN__) -#include -// Undef GetUserName defined by windows.h so we won't conflict with -// blaze_util::GetUserName -#undef GetUserName -#endif // defined(COMPILER_MSVC) || defined(__CYGWIN__) - #include #include @@ -61,7 +54,13 @@ IFileMtime *CreateFileMtime(); std::pair SplitPath(const std::string &path); #if defined(COMPILER_MSVC) || defined(__CYGWIN__) -typedef HANDLE file_handle_type; +// We cannot include because it #defines many symbols that conflict +// with our function names, e.g. GetUserName, SendMessage. +// Instead of typedef'ing HANDLE, let's use the actual type, void*. If that ever +// changes in the future and HANDLE would no longer be compatible with void* +// (very unlikely, given how fundamental this type is in Windows), then we'd get +// a compilation error. +typedef /* HANDLE */ void *file_handle_type; #else // !(defined(COMPILER_MSVC) || defined(__CYGWIN__)) typedef int file_handle_type; #endif // defined(COMPILER_MSVC) || defined(__CYGWIN__) -- cgit v1.2.3