【问题标题】:Clang++ -fmodules errors using types after #include <cstdint>在#include <cstdint> 之后使用类型的 Clang++ -fmodules 错误
【发布时间】: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


    【解决方案1】:

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

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

    【讨论】:

    • 我很高兴你说你已经修复了这个问题,因为我今天已经更新了我的 libcxx 源并构建了它,只是为了看看这个错误是否偶然自我上次更新以来已修复,但它仍然不适合我。但是看到你的回答,我有动力更努力地看。事实证明,虽然我为 LLVM 运行了 make,但我还没有运行 make install。德普。它现在正在工作。非常感谢。
    • 别担心!测试 C++ 新功能的人越多越好。
    猜你喜欢
    • 2020-10-25
    • 2014-07-02
    • 1970-01-01
    • 1970-01-01
    • 2016-08-24
    • 2020-05-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多