【发布时间】:2016-01-23 07:17:39
【问题描述】:
模块是#includes 的替代品。 Clang has a complete implementation for C++。如果我现在想通过 Clang 使用模块,我该怎么做?
使用
import std.io;
在 C++ 源文件中还不能工作(编译),因为模块规范(包括语法)不是最终的。
Clang documentation 声明,当传递-fmodules 标志时,#includes 将被重写为相应的导入。但是,检查预处理器会提示其他情况(test.cpp 仅包含 #include <stdio.h> 和一个空的 main):
$ clang++-3.5 -fmodules -E test.cpp -o test
$ grep " printf " test
extern int printf (const char *__restrict __format, ...);
此外,使用 -fmodules 与完全不使用标志编译此测试文件会产生相同的目标文件。
我做错了什么?
【问题讨论】:
标签: c++ clang c++20 c++-modules