VC++ 实验模块不起作用
VC++ experimental modules does not work
我正在尝试Visual Studio 2017版本15.4.4中模块的实验性实现。我按照此处描述的说明进行操作 https://blogs.msdn.microsoft.com/vcblog/2017/05/05/cpp-modules-in-visual-studio-2017/。我能够在控制台应用程序中快速运行。
import std.core;
int main()
{
std::cout << "Hello modules!" << std::endl;
return 0;
}
导入和使用可用的标准模块不是问题(就我尝试到目前为止而言(。
但是,当我定义自己的模块时,没有任何效果。我添加了一个文件系统.ixx(项目类型C/C++编译器(,内容如下:
import std.core;
export import system.io;
export struct console
{
void write(std::string_view text) { std::cout << text; }
void write_line(std::string_view text) { std::cout << text << std::endl; }
};
当我将import system.io
添加到主.cpp
import std.core;
import system.io;
int main()
{
std::cout << "Hello modules!" << std::endl;
return 0;
}
我收到以下错误:
1>system.ixx
1>system.ixx(2): error C2230: could not find module 'system.io'
1>main.cpp
1>main.cpp(2): error C2230: could not find module 'system.io'
我还在编译器选项中添加了/module:reference system.io.idf
,但是没有从system.ixx生成的system.io.idf文件。
我知道这是实验性的,有很多问题,但我想知道我应该做些什么来使这个简单的事情工作。
在system.ixx
中,尝试将export import system.io
更改为export module system.io
。您还需要确保export module ...
声明显示在文件顶部。所以system.ixx
变成:
export module system.io;
import std.core;
export struct console
{
void write(std::string_view text) { std::cout << text; }
void write_line(std::string_view text) { std::cout << text << std::endl; }
};
相关文章:
- 我的神经网络不起作用 [XOR 问题]
- 在C++程序中输入的文本文件将不起作用,除非文本被复制和粘贴
- C++映射:具有自定义类的运算符[]不起作用(总是返回0)
- C++为什么尽管我调用了void函数,它却不起作用
- 为什么在保护模式下继承升级不起作用
- 循环在计数器中不起作用
- 在其他文件中创建类时在 c++ 项目中不起作用
- Visual studio代码重构似乎不起作用(例如,重命名符号-f2)
- 为什么二进制搜索在我的测试中不起作用
- 我的代码中有错误吗?使用BGI图形的C++代码对我不起作用
- 为什么 const std::p air<K,V>& 在 std::map 上基于范围的 for 循环不起作用?
- 带有指定长度字符* 参数的 std::regex_search 在 VS2017 中不起作用?
- Bjarne Stroustrup Book - std_lib_facilities.h - 不起作用(未知类型名称)
- 为什么简单的算术减法在"if"条件下不起作用?
- 为什么Stroustup书中的has_f不起作用
- 你能检查一下为什么在这个代码中从链接列表中删除项目不起作用吗
- 嵌套While循环不起作用(C++问题)
- C++Matching Brackets 2解决方案不起作用
- qt.bluetooth:虚拟后端正在运行.Qt蓝牙模块在Raspbian上不起作用
- VC++ 实验模块不起作用