萌新求助,请问在 Clion(2023.3.3)中使用 C++Modules 的正确方式是什么?

35次阅读

共计 131 个字符,预计需要花费 1 分钟才能阅读完成。

各位大佬好,我最近在学习 C++,使用的是《C++20 入门实践》这本书,里面第一个 Demo 就是使用 C++Modules 编写成的,但是我发现书中的代码我在 Clion 中编译报错。

代码如下:

import ;

int main() {int answer{42};
    std::cout << "The answer to life, the universe, and everything is"
              << answer
              <

相关图片及说明: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?

正文完
 0