首页 > 解决方案 > VS2022 i"mport std.core" 编译需要安装什么

问题描述

当我使用以下内容时,

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

解决方案


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

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


推荐阅读