VS2022“导入std.core”需要安装什么才能编译?

问题描述 投票:0回答:2

当我使用以下内容时:

import std.core;

我收到错误:

Error   C1011   cannot locate standard module interface. Did you install the library part of the C++ modules feature in VS setup?

我检查了安装,但找不到如何安装 C++ 模块功能。我还担心这不够标准,无法在 gcc 11.2.0 和 VS2022 上编译。

g++ visual-studio-2022
2个回答
2
投票
  1. 打开 Visual Studio 安装程序并确保安装了 v143 构建工具的 C++ 模块(x64/x86 - 实验性)
  2. 打开您的项目,转到 Properties -> C/C++ -> Languages -> Enable Experimental C++ Standard Library Modules 并将其设置为 Yes (/experimental:module))

它仍然是一个实验性功能,因此在导入 std 模块时您可能会收到一些 C5050 警告。如需了解更多信息,您可以访问 https://learn.microsoft.com/en-us/cpp/cpp/modules-cpp?view=msvc-170


0
投票

MS 在引入“import std.core;”时“操之过急”在C++23正式采用如何导入模块之前。使用 C++23,您可以导入 std;或 std.compat;

使用最新的 VS 2022 版本,甚至对于 C++23,您不再需要实验模块功能。只需确保您的语言标准是 Preview,/std::c++latest。

© www.soinside.com 2019 - 2024. All rights reserved.