[libcxx-commits] [PATCH] D136683: [libc++] Only include_next C library headers when they exist
Louis Dionne via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Feb 5 06:00:08 PST 2023
ldionne added a comment.
In D136683#4013790 <https://reviews.llvm.org/D136683#4013790>, @thakis wrote:
> I just noticed that this leads to atrocious diagnostics:
>
> % cat hello.cc
> #include <stdio.h>
> int main() { printf("hello\n"); }
>
> % out/gn/bin/clang -c hello.cc
> hello.cc:2:14: error: use of undeclared identifier 'printf'
>
> ???
>
> This works:
>
> % out/gn/bin/clang -c hello.cc -isysroot $(xcrun -show-sdk-path)
>
> The reason is that stdio.h picks up libc++'s stdio.h, which then only include_next's the actual stdio.h if it exists.
>
> This seems suboptimal (?)
Yes, I've noticed that before, but I don't see a solution to this other than getting rid of libc++'s `stdio.h` header entirely (and same for other C compatibility headers). This is a tradeoff between diagnostics quality and libc++'s ability to work on top of freestanding implementations without much work.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D136683/new/
https://reviews.llvm.org/D136683
More information about the libcxx-commits
mailing list