build: fix minor compiler errors when building with VS2026 (#13744)
* build: fix minor compiler errors when building with VS2026 * s * use VS2022 for clang format and cross compiling --------- Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
Ben Hillis committed
Nov 19, 2025 at 15:35 UTC
b73897e88a0d023a86d3ae7f8c423b6479d9314d
3 files changed
+18
-17
CMakeLists.txt
+3
-2
@@ -266,15 +266,16 @@ else()
266
endif()
267
268
# Determine the Visual Studio installation directory which contains LLVM tools
269
+# N.B. The version is set to VS2022 to ensure local runs match pipeline behavior
270
execute_process(
270
- COMMAND "${VSWHERE_SOURCE_DIR}/vswhere.exe" -latest -products * -property installationPath
271
+ COMMAND "${VSWHERE_SOURCE_DIR}/vswhere.exe" -version "[17.0,18.0)" -products * -property installationPath
272
OUTPUT_VARIABLE VS_INSTALL_DIR
273
OUTPUT_STRIP_TRAILING_WHITESPACE
274
COMMAND_ERROR_IS_FATAL ANY
275
)
276
277
if (NOT VS_INSTALL_DIR)
277
- message(FATAL_ERROR "Could not determine Visual Studio installation directory.")
278
+ message(FATAL_ERROR "Could not determine Visual Studio 2022 installation directory.")
279
endif()
280
281
if("${CMAKE_HOST_SYSTEM_PROCESSOR}" STREQUAL "AMD64")
test/windows/DrvFsTests.cpp
+1
-1
@@ -791,7 +791,7 @@ private:
791
} Data;
792
} Reparse{};
793
794
- constexpr ULONG ReparseBufferSize = REPARSE_DATA_BUFFER_HEADER_SIZE + sizeof(ULONG);
794
+ const ULONG ReparseBufferSize = REPARSE_DATA_BUFFER_HEADER_SIZE + sizeof(ULONG);
795
796
//
797
// The data length is the buffer size excluding the header.
test/windows/UnitTests.cpp
+14
-14
@@ -2797,7 +2797,7 @@ Error code: Wsl/InstallDistro/WSL_E_DISTRO_NOT_FOUND
2797
2798
VERIFY_ARE_EQUAL(LxsstuLaunchWsl(std::format(L"--import {} . \"{}\" --version 2", name, g_testDistroPath)), 0L);
2799
2800
- auto cleanupName = wil::scope_exit_log(WI_DIAGNOSTICS_INFO, []() {
2800
+ auto cleanupName = wil::scope_exit_log(WI_DIAGNOSTICS_INFO, [name]() {
2801
LxsstuLaunchWsl(std::format(L"--unregister {}", name));
2802
std::filesystem::remove_all(testFolder);
2803
});
@@ -2873,9 +2873,9 @@ Error code: Wsl/InstallDistro/WSL_E_DISTRO_NOT_FOUND
2873
WslShutdown();
2874
2875
auto cleanupName =
2876
- wil::scope_exit_log(WI_DIAGNOSTICS_INFO, []() { LxsstuLaunchWsl(std::format(L"--unregister {}", name)); });
2876
+ wil::scope_exit_log(WI_DIAGNOSTICS_INFO, [name]() { LxsstuLaunchWsl(std::format(L"--unregister {}", name)); });
2877
2878
- auto validateDistro = [](LPCWSTR size, LPCWSTR expectedSize, LPCWSTR expectedError = nullptr) {
2878
+ auto validateDistro = [name](LPCWSTR size, LPCWSTR expectedSize, LPCWSTR expectedError = nullptr) {
2879
auto [out, _] = LxsstuLaunchWslAndCaptureOutput(std::format(L"--manage {} --resize {}", name, size), expectedError ? -1 : 0);
2880
if (expectedError)
2881
{
@@ -3578,8 +3578,8 @@ localhostForwarding=true
3578
3579
constexpr auto TestUser = L"testuser";
3580
3581
- auto cleanup =
3582
- wil::scope_exit_log(WI_DIAGNOSTICS_INFO, []() { LxsstuLaunchWsl(std::format(L"-u root userdel -f {}", TestUser)); });
3581
+ auto cleanup = wil::scope_exit_log(
3582
+ WI_DIAGNOSTICS_INFO, [TestUser]() { LxsstuLaunchWsl(std::format(L"-u root userdel -f {}", TestUser)); });
3583
3584
ULONG Uid{};
3585
ULONG Gid{};
@@ -3719,7 +3719,7 @@ localhostForwarding=true
3719
constexpr auto testTar = L"exported-distro.tar";
3720
constexpr auto tmpDistroName = L"tmpdistro";
3721
3722
- auto cleanup = wil::scope_exit_log(WI_DIAGNOSTICS_INFO, []() {
3722
+ auto cleanup = wil::scope_exit_log(WI_DIAGNOSTICS_INFO, [tmpDistroName]() {
3723
DeleteFile(testTar);
3724
LxsstuLaunchWsl(std::format(L"--unregister {}", tmpDistroName));
3725
});
@@ -3950,7 +3950,7 @@ VERSION_ID="Invalid|Format"
3950
constexpr auto testDistroName = L"test-oobe-import";
3951
3952
std::filesystem::create_directory(testDir);
3953
- auto cleanup = wil::scope_exit_log(WI_DIAGNOSTICS_INFO, [this]() {
3953
+ auto cleanup = wil::scope_exit_log(WI_DIAGNOSTICS_INFO, [this, testDistroName]() {
3954
LxsstuLaunchWsl(std::format(L"--unregister {}", testDistroName));
3955
std::error_code error;
3956
std::filesystem::remove_all(testDir, error);
@@ -4511,7 +4511,7 @@ Error code: Wsl/Service/RegisterDistro/E_INVALIDARG\r\n";
4511
constexpr auto distroName = L"custom-terminal-profile";
4512
constexpr auto tarName = L"custom-terminal-profile.tar";
4513
4514
- auto cleanup = wil::scope_exit_log(WI_DIAGNOSTICS_INFO, []() {
4514
+ auto cleanup = wil::scope_exit_log(WI_DIAGNOSTICS_INFO, [distroName]() {
4515
DeleteFile(tarName);
4516
LxsstuLaunchWsl(std::format(L"--unregister {}", distroName));
4517
});
@@ -4553,7 +4553,7 @@ Error code: Wsl/Service/RegisterDistro/E_INVALIDARG\r\n";
4553
constexpr auto distroName = L"custom-terminal-profile-bad-json";
4554
constexpr auto tarName = L"custom-terminal-profile-bad-json.tar";
4555
4556
- auto cleanup = wil::scope_exit_log(WI_DIAGNOSTICS_INFO, []() {
4556
+ auto cleanup = wil::scope_exit_log(WI_DIAGNOSTICS_INFO, [distroName]() {
4557
DeleteFile(tarName);
4558
LxsstuLaunchWsl(std::format(L"--unregister {}", distroName));
4559
});
@@ -4581,7 +4581,7 @@ Error code: Wsl/Service/RegisterDistro/E_INVALIDARG\r\n";
4581
constexpr auto distroName = L"custom-terminal-profile-hide";
4582
constexpr auto tarName = L"custom-terminal-profile-hide.tar";
4583
4584
- auto cleanup = wil::scope_exit_log(WI_DIAGNOSTICS_INFO, []() {
4584
+ auto cleanup = wil::scope_exit_log(WI_DIAGNOSTICS_INFO, [distroName]() {
4585
DeleteFile(tarName);
4586
LxsstuLaunchWsl(std::format(L"--unregister {}", distroName));
4587
});
@@ -4625,7 +4625,7 @@ Error code: Wsl/Service/RegisterDistro/E_INVALIDARG\r\n";
4625
constexpr auto distroName = L"no-terminal-profile";
4626
constexpr auto tarName = L"no-terminal-profile.tar";
4627
4628
- auto cleanup = wil::scope_exit_log(WI_DIAGNOSTICS_INFO, []() {
4628
+ auto cleanup = wil::scope_exit_log(WI_DIAGNOSTICS_INFO, [distroName]() {
4629
DeleteFile(tarName);
4630
LxsstuLaunchWsl(std::format(L"--unregister {}", distroName));
4631
});
@@ -4647,7 +4647,7 @@ Error code: Wsl/Service/RegisterDistro/E_INVALIDARG\r\n";
4647
constexpr auto distroName = L"no-shortcut";
4648
constexpr auto tarName = L"no-shortcut.tar";
4649
4650
- auto cleanup = wil::scope_exit_log(WI_DIAGNOSTICS_INFO, []() {
4650
+ auto cleanup = wil::scope_exit_log(WI_DIAGNOSTICS_INFO, [distroName]() {
4651
DeleteFile(tarName);
4652
LxsstuLaunchWsl(std::format(L"--unregister {}", distroName));
4653
});
@@ -6146,8 +6146,8 @@ Error code: Wsl/InstallDistro/WSL_E_INVALID_JSON\r\n",
6146
TEST_METHOD(ImportExportStdout)
6147
{
6148
constexpr auto test_distro = L"import-test-distro";
6149
- auto cleanup =
6150
- wil::scope_exit_log(WI_DIAGNOSTICS_INFO, []() { LxsstuLaunchWsl(std::format(L"--unregister {}", test_distro)); });
6149
+ auto cleanup = wil::scope_exit_log(
6150
+ WI_DIAGNOSTICS_INFO, [test_distro]() { LxsstuLaunchWsl(std::format(L"--unregister {}", test_distro)); });
6151
6152
// The below logline makes it easier to find the bsdtar output when debugging this test case.
6153
fprintf(stderr, "Starting ImportExportStdout test case\n");