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

Clang++ -fmodules errors using types after #include <cstdint>

本文关键字:gt cstdint 类型 lt 错误 #include Clang++ fmodules      更新时间:2023-10-16

以下简单的测试用例文件给了我一个编译时错误,当使用-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 的功能"reflexpr"分支的提交):

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 构建的标头与/usr/local/include/usr/include中的 OS X 系统标头之间的交互

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

在过去的一个月里,我已经修复了将libc ++与模块一起使用的许多问题。从字面上看,我昨天只在启用模块的情况下通过了所有 libc++ 测试。