summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2016-11-08 04:36:32 (GMT)
committerNico Weber <thakis@chromium.org>2016-11-08 04:36:32 (GMT)
commit32c82da13e2d16792c79507be3d875a6e4624423 (patch)
tree3f7d303c18a4cbe31732953328a41c46a8c0a933
parent2263f82beab801f5d0235790e651142dba202ae8 (diff)
downloadNinja-32c82da13e2d16792c79507be3d875a6e4624423.zip
Ninja-32c82da13e2d16792c79507be3d875a6e4624423.tar.gz
Ninja-32c82da13e2d16792c79507be3d875a6e4624423.tar.bz2
windows: replace deprecated GetVersionEx with recommended replacement
The recommended replacement VerifyVersionInfo should work with the same SDKs that GetVersionEx worked with (while the wrappers in VersionHelpers.h require a recent SDK). This patch should not change behavior, and it's not supposed to increase build requirements. If this makes things harder to build, please let me know.
-rw-r--r--src/disk_interface.cc19
1 files changed, 7 insertions, 12 deletions
diff --git a/src/disk_interface.cc b/src/disk_interface.cc
index 451a9b4..1b4135f 100644
--- a/src/disk_interface.cc
+++ b/src/disk_interface.cc
@@ -80,20 +80,15 @@ TimeStamp StatSingleFile(const string& path, string* err) {
return TimeStampFromFileTime(attrs.ftLastWriteTime);
}
-#ifdef _MSC_VER
-#pragma warning(push)
-#pragma warning(disable: 4996) // GetVersionExA is deprecated post SDK 8.1.
-#endif
bool IsWindows7OrLater() {
- OSVERSIONINFO version_info = { sizeof(version_info) };
- if (!GetVersionEx(&version_info))
- Fatal("GetVersionEx: %s", GetLastErrorString().c_str());
- return version_info.dwMajorVersion > 6 ||
- (version_info.dwMajorVersion == 6 && version_info.dwMinorVersion >= 1);
+ OSVERSIONINFOEX version_info =
+ { sizeof(OSVERSIONINFOEX), 6, 1, 0, 0, {0}, 0, 0, 0, 0, 0};
+ DWORDLONG comparison = 0;
+ VER_SET_CONDITION(comparison, VER_MAJORVERSION, VER_GREATER_EQUAL);
+ VER_SET_CONDITION(comparison, VER_MINORVERSION, VER_GREATER_EQUAL);
+ return VerifyVersionInfo(
+ &version_info, VER_MAJORVERSION | VER_MINORVERSION, comparison);
}
-#ifdef _MSC_VER
-#pragma warning(pop)
-#endif
bool StatAllFilesInDir(const string& dir, map<string, TimeStamp>* stamps,
string* err) {