win: Disable deprecation warning for one call of GetVersionEx

Like https://chromium-review.googlesource.com/c/chromium/src/+/3207949
but using pragmas that work with both cl.exe and (very new versions of)
clang-cl.

webrtc also needs the granularity, see e.g.
https://webrtc-review.googlesource.com/c/src/+/229140

Bug: chromium:1255114
Change-Id: I6a2bf9447f377988a2a3844d6ef16aeee63734f7
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/234420
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Nico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/main@{#35158}
This commit is contained in:
Nico Weber
2021-10-06 11:32:06 -04:00
committed by WebRTC LUCI CQ
parent fc5a4f74ac
commit bde89ab09e

View File

@ -275,9 +275,12 @@ OSInfo::OSInfo()
// Windows 8 OS version value (6.2). Once an application is manifested for a // Windows 8 OS version value (6.2). Once an application is manifested for a
// given operating system version, GetVersionEx() will always return the // given operating system version, GetVersionEx() will always return the
// version that the application is manifested for in future releases. // version that the application is manifested for in future releases.
// https://docs.microsoft.com/en-us/windows/desktop/SysInfo/targeting-your-application-at-windows-8-1. // https://docs.microsoft.com/en-us/windows/desktop/SysInfo/targeting-your-application-at-windows-8-1
// https://www.codeproject.com/Articles/678606/Part-Overcoming-Windows-s-deprecation-of-GetVe. // https://www.codeproject.com/Articles/678606/Part-Overcoming-Windows-s-deprecation-of-GetVe
#pragma warning(push)
#pragma warning(disable : 4996)
::GetVersionExW(reinterpret_cast<OSVERSIONINFOW*>(&version_info)); ::GetVersionExW(reinterpret_cast<OSVERSIONINFOW*>(&version_info));
#pragma warning(pop)
version_number_.major = version_info.dwMajorVersion; version_number_.major = version_info.dwMajorVersion;
version_number_.minor = version_info.dwMinorVersion; version_number_.minor = version_info.dwMinorVersion;
version_number_.build = version_info.dwBuildNumber; version_number_.build = version_info.dwBuildNumber;