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

萝らか妹 提交于 2019-12-13 13:16:49

问题


The following simple test case file is giving me a compile-time error with the tip of 'master' from Clang's github mirror, when compiled with -fmodules, using the command shown below. I'm wondering if this is a bug with the new experimental Module feature for Clang -- maybe a problem with the implementation of module maps for the standard library -- or if there's something I'm doing wrong. The error still appears if I add -fbuiltin-module-map to the command. Interestingly, the error no longer appears if I substitute stdint.h for cstdint.

#include <stdint.h>
uint64_t foo;

Here's my compile command, with the error message:

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;

Information on the build I'm using: It's from Matus Chochlik's fork of the github Clang mirror; but I'm set to the commit that corresponds to the (at the time) head of 'master' in the original clang git mirror (in other words, it does not include commits from Matus Chochlik's feature 'reflexpr' branch):

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

(Note: suspecting this is a bug, I have also emailed the above report to the LLVM Administrators and intend to file it at the LLVM Bugzilla if they reply and give me a login. But I thought I'd post it here as well, in case it's something I'm getting wrong, or is interesting to anyone working with Clang's C++1z+ modules support)

Edit 1:

If I add the -v to the compile command-line, it shows that it is indeed searching my build's include directories, not those of another build of Clang, for example:

#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.

I don't know if the issue could be an interaction between my Clang build's headers and the OS X system headers in /usr/local/include and /usr/include


回答1:


This was an issue in libc++ which I fixed in r287690. If you update your custom Clang/libc++ installation these issues should be fixed.

Over the past month I've fixed a number of issues using libc++ with modules. I literally only got all of the libc++ tests passing yesterday with modules enabled.



来源:https://stackoverflow.com/questions/41028251/clang-fmodules-errors-using-types-after-include-cstdint

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!