我apt.llvm.org使用apt
包管理器从www.example.com仓库安装了LLVM+Clang,但是我不能正确使用它。
$ clang++ -E -v -
Debian clang version 15.0.7
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/i686-linux-gnu/8
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/8
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/8
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64
...
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/llvm-15/lib/clang/15.0.7/include
/usr/local/include
/usr/include/x86_64-linux-gnu
/include
/usr/include
它不包含Clang的libc++
头文件的实际路径。
#include <type_traits>
enum A { B };
int main() { std::is_scoped_enum_v<A>; }
无法编译:
$ clang++ main.cc -std=c++2b
main.cc:4:19: error: no member named 'is_scoped_enum_v' in namespace 'std'
int main() { std::is_scoped_enum_v<A>; }
~~~~~^
main.cc:4:36: error: 'A' does not refer to a value
int main() { std::is_scoped_enum_v<A>; }
^
main.cc:3:6: note: declared here
enum A { B };
^
main.cc:4:38: error: expected expression
int main() { std::is_scoped_enum_v<A>; }
^
3 errors generated.
虽然它是完全可编译的代码:https://godbolt.org/z/YP33v7Y9a
我该怎么补救?
环境:
- 操作系统:
Debian Buster
- 内核:
4.19.0-23-amd64 #1 SMP Debian 4.19.269-1 (2022-12-20) x86_64 GNU/Linux
- 海湾合作委员会:
(Debian 8.3.0-6) 8.3.0
- 叮当声:
Debian clang version 15.0.7
我是如何安装LLVM+Clang的?
在Debian Buster中使用从https://apt.llvm.org复制的存储库中的apt
:deb http://apt.llvm.org/buster/ llvm-toolchain-buster-15 main deb-src http://apt.llvm.org/buster/ llvm-toolchain-buster-15 main
1条答案
按热度按时间watbbzwu1#
这是已知的行为,它使用Debian和Ubuntu上的系统默认GCC C运行时来减少构建应用对其他库的依赖。如果你想使用Clang C库,请使用
-stdlib=libc++
: