当我使用以下内容时:
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 上编译。
它仍然是一个实验性功能,因此在导入 std 模块时您可能会收到一些 C5050 警告。如需了解更多信息,您可以访问 https://learn.microsoft.com/en-us/cpp/cpp/modules-cpp?view=msvc-170
MS 在引入“import std.core;”时“操之过急”在C++23正式采用如何导入模块之前。使用 C++23,您可以导入 std;或 std.compat;
使用最新的 VS 2022 版本,甚至对于 C++23,您不再需要实验模块功能。只需确保您的语言标准是 Preview,/std::c++latest。