【发布时间】:2016-12-07 22:07:01
【问题描述】:
当使用-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 系统标头之间的交互
【问题讨论】:
标签: c++ clang++ c++17 libc++ c++-modules