c++ - 在#include <cstdint> 之后使用类型的 Clang++ -fmodules 错误

标签 c++ clang++ c++17 libc++ c++-modules

当使用 -fmodules 编译时,以下简单的测试用例文件给我一个编译时错误,提示来自 Clang 的 github 镜像的“master” ,使用如下所示的命令。我想知道这是否是 Clang 的新实验模块功能的错误——可能是标准库的模块映射实现的问题——或者我做错了什么。如果我添加 -fbuiltin-module-map,错误仍然出现到命令。有趣的是,如果我替换 stdint.h,错误不再出现对于 cstdint .

#include <stdint.h>
uint64_t foo;

这是我的编译命令,带有错误信息:

anhall@leviathan: /Users/anhall/impersonal/code/llvm-reflexpr/install/bin/clang++ -o module-uint64_t-test.o -c module-uint64_t-test.cpp --std=c++1z -fmodules
module-uint64_t-test.cpp:3:1: error: missing '#include <_types/_uint64_t.h>'; declaration of 'uint64_t' must be imported from module 'Darwin.POSIX._types._uint64_t' before it is
      required
uint64_t foo;
^
/usr/include/_types/_uint64_t.h:31:28: note: previous declaration is here
typedef unsigned long long uint64_t;

关于我正在使用的构建的信息:它来自 Matus Chochlik 的 github Clang 镜像的分支;但我设置为对应于原始 clang git 镜像中“master”的(当时)负责人的提交(换句话说,它不包括来自 Matus Chochlik 的功能“refflexpr”分支的提交):

anhall@leviathan: /Users/anhall/impersonal/code/llvm-reflexpr/install/bin/clang++ -v
clang version 4.0.0 (https://github.com/matus-chochlik/clang.git 1fa85026bfc23f5cda0b89598bd2056b817ae9d4) (https://github.com/llvm-mirror/llvm.git 069db88a3b2cae52023664fdd30378d3adc26566)
Target: x86_64-apple-darwin15.6.0
Thread model: posix
InstalledDir: /Users/anhall/impersonal/code/llvm-reflexpr/install/bin

(注意:怀疑这是一个错误,我还通过电子邮件将上述报告发送给 LLVM 管理员,如果他们回复并给我登录,我打算将其提交到 LLVM Bugzilla。但我想我应该把它贴在这里同样,以防万一我弄错了,或者对使用 Clang 的 C++1z+ 模块支持的任何人都感兴趣)

编辑 1:

如果我添加 -v到编译命令行,它表明它确实在搜索我构建的 include目录,而不是另一个 Clang 版本的目录,例如:

#include "..." search starts here:
#include <...> search starts here:
 /Users/anhall/impersonal/code/llvm-reflexpr/install/bin/../include/c++/v1
 /usr/local/include
 /Users/anhall/impersonal/code/llvm-reflexpr/install/bin/../lib/clang/4.0.0/include
 /usr/include
 /System/Library/Frameworks (framework directory)
 /Library/Frameworks (framework directory)
End of search list.

我不知道问题是否可能是我的 Clang 构建 header 与 /usr/local/include 中的 OS X 系统 header 之间的交互和 /usr/include

最佳答案

这是我在 r287690 中修复的 libc++ 中的一个问题.如果您更新您的自定义 Clang/libc++ 安装,这些问题应该得到解决。

在过去的一个月里,我解决了一些使用带有模块的 libc++ 的问题。我真的只是昨天在启用模块的情况下通过了所有 libc++ 测试。

关于c++ - 在#include <cstdint> 之后使用类型的 Clang++ -fmodules 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41028251/

相关文章:

c++ - 为什么模板别名特化取决于引用它的上下文?

c++ - 如果语句包含宏,则 clang 无法替换语句

c++ - Lambda 捕获数组元素失败

C++ STL 方法从字符串中提取子字符串 from -> to (like Javascript substring)

c++ - 向数组移动和添加元素

linux - 带有 clang++ 和 libc++ 的 linux 上的 std::cerr 导致 SIGABRT

c++ - C++17 中的折叠表达式 - 比较运算符的用例

c++ - 如何在声明和定义中拆分静态 lambda?

c++ - 带有重载 lambda 的 std::variant,用 MSVC 替代?

c++ - 按概率对 if...else if 语句进行排序的效果是什么?