From d1e6a29fd30337e86c346208661c00233fd223f7 Mon Sep 17 00:00:00 2001 From: Beren Minor Date: Wed, 31 Dec 2014 12:17:21 +0100 Subject: Fix compilation errors on Visual Studio 2015 (_MSC_VER 1900). --- configure.py | 2 ++ src/deps_log.cc | 4 ++-- src/hash_map.h | 21 +++++++++++++++++++-- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/configure.py b/configure.py index 0f34e77..fe71372 100755 --- a/configure.py +++ b/configure.py @@ -284,6 +284,8 @@ if platform.is_msvc(): '/wd4512', '/wd4800', '/wd4702', '/wd4819', # Disable warnings about passing "this" during initialization. '/wd4355', + # Disable warnings about ignored typedef in DbgHelp.h + '/wd4091', '/GR-', # Disable RTTI. # Disable size_t -> int truncation warning. # We never have strings or arrays larger than 2**31. diff --git a/src/deps_log.cc b/src/deps_log.cc index aa8eb23..bd47ebc 100644 --- a/src/deps_log.cc +++ b/src/deps_log.cc @@ -239,13 +239,13 @@ bool DepsLog::Load(const string& path, State* state, string* err) { if (buf[path_size - 1] == '\0') --path_size; if (buf[path_size - 1] == '\0') --path_size; if (buf[path_size - 1] == '\0') --path_size; - StringPiece path(buf, path_size); + StringPiece subpath(buf, path_size); // It is not necessary to pass in a correct slash_bits here. It will // either be a Node that's in the manifest (in which case it will already // have a correct slash_bits that GetNode will look up), or it is an // implicit dependency from a .d which does not affect the build command // (and so need not have its slashes maintained). - Node* node = state->GetNode(path, 0); + Node* node = state->GetNode(subpath, 0); // Check that the expected index matches the actual index. This can only // happen if two ninja processes write to the same deps log concurrently. diff --git a/src/hash_map.h b/src/hash_map.h index 77e7586..9b98ca8 100644 --- a/src/hash_map.h +++ b/src/hash_map.h @@ -50,7 +50,22 @@ unsigned int MurmurHash2(const void* key, size_t len) { return h; } -#ifdef _MSC_VER +#if (__cplusplus >= 201103L) || (_MSC_VER >= 1900) +#include + +namespace std { +template<> +struct hash { + typedef StringPiece argument_type; + typedef std::size_t result_type; + + result_type operator()(argument_type const& s) const { + return MurmurHash2(s.str_, s.len_); + } +}; +} + +#elif defined(_MSC_VER) #include using stdext::hash_map; @@ -102,7 +117,9 @@ struct hash { /// mapping StringPiece => Foo*. template struct ExternalStringHashMap { -#ifdef _MSC_VER +#if (__cplusplus >= 201103L) || (_MSC_VER >= 1900) + typedef std::unordered_map Type; +#elif defined(_MSC_VER) typedef hash_map Type; #else typedef hash_map Type; -- cgit v0.12