【发布时间】:2020-10-07 18:34:54
【问题描述】:
Visual Studio 2019 不会尝试编译我的 .cxx 或 .ixx 文件。这是我的 .cxx 文件:
export module greetings;
import std.core;
export std::string get_greeting_text()
{
return "Hello, World!";
}
这是主要的:
import std.core;
import greetings;
int main()
{
std::cout << get_greeting_text() << '\n';
}
我确实设置了这些标志:/std:c++latest、/experimental:module。错误信息是
C:\...\main.cpp(2,17):error C2230: could not find module 'greetings'
C:\...\main.cpp(6,2): error C3861: 'get_greeting_text': identifier not found
...但是我没有看到任何关于尝试编译 greetings.cxx 的行,所以这一定是问题所在。将其更改为 .ixx 无效。解决方法是什么?
【问题讨论】:
-
import和export何时成为 C++ 的一部分? -
@ThomasMatthews 自 c++ 20 以来:en.cppreference.com/w/cpp/language/modules
标签: c++ visual-c++ c++20 c++-modules