I have a Visual Studio C++ project, and after updating Visual Studio 2022 recently from version 17.5 to version 17.6, the compilation stops in the very beginning with the error:
1>------ Rebuild All started: Project: MRPch, Configuration: Debug x64 ------
1>Scanning sources for module dependencies...
1>std.compat.ixx
1>std.ixx
1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\modules\std.compat.ixx : fatal error C1083: Cannot open include file: 'MRPch.h': No such file or directory
1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\modules\std.ixx : fatal error C1083: Cannot open include file: 'MRPch.h': No such file or directory
1>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(486,5): warning MSB8074: Cannot read Module Dependencies file C:\Work\MeshInspector\source\TempOutput\MRPch\x64\Debug\std.ixx.module.json: Expecting element 'root' from namespace ''.. Encountered 'None' with name '', namespace ''. The build order might be incorrect.
1>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(486,5): warning MSB8074: Cannot read Module Dependencies file C:\Work\MeshInspector\source\TempOutput\MRPch\x64\Debug\std.compat.ixx.module.json: Expecting element 'root' from namespace ''.. Encountered 'None' with name '', namespace ''. The build order might be incorrect.
As far as I can see, it is somehow related to the precompiled header MRPch.h
, which is forcedly included in all source files via the compiler option /FI"MRPch.h"
.
If I remove forced include, then the error changes to
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\modules\std.ixx(147,1): fatal error C1010: unexpected end of file while looking for precompiled header.
There are neither std.compat.ixx
nor std.ixx
in my project, but I found that the error is somehow related to /std:c++latest
command-line option, which enables the latest language features.
I looked at Visual Studio 2022 version 17.6 Release Notes, but did not see anything related to precompiled headers there. Are they no longer compatible with the latest C++ standard?
To fix this problem, change this setting: Project properties > C/C++ > Language > Build ISO C++23 Standard Library Modules > No.