各位大佬好,我最近在学习 C++,使用的是《 C++20 入门实践》这本书,里面第一个 Demo 就是使用 C++Modules 编写成的,但是我发现书中的代码我在 Clion 中编译报错。
代码如下:
import <iostream>;
int main() {
int answer{42};
std::cout << "The answer to life, the universe, and everything is "
<< answer
<< std::endl;
}
相关图片及说明: https://imgur.com/a/MGRU5qD
另外我在 Clion 的官方网站上 https://www.jetbrains.com/help/clion/support-for-c-20-modules.html 找到关于 C++ Modules 的支持情况, 里面有说到
For now, CLion does not consider .cpp files to be modules, so it's recommended that you use other extensions (for example, .cppm).
我把文件的扩展名改为 .cppm 后,也是报错的。 最后,我想请问下如何优雅的在 Clion 中使用 C++ Modules ?