[Topic DIscussion] 找不到C++标准库相关头文件
Tofloor
poster avatar
画卦伏羲
deepin
2022-06-29 10:07
Author

vscode + clang + clangd + cmake

CMakelists.txt中写入:

...
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED true)
...

main.cpp中(代码是从 cppreference上复制下来的,编译结果 concepts头文件找不到):

#include 
#include 
 
template
concept IsAnyOf = (std::same_as || ...);
 
template
concept IsPrintable = std::integral || std::floating_point ||
    IsAnyOf>>, char, wchar_t>;
 
void println(IsPrintable auto const ... arguments)
{
    (std::wcout << ... << arguments) << '\n';
}
 
int main() { println("Example: ", 3.14, " : ", 42, " : [", 'a', L'-', L"Z]"); }

编译输出:

/data/home/FuXii/Projects/Turbo/samples/CPPStandardTest.cpp:1:10: fatal error: 'concepts' file not found
#include 
         ^~~~~~~~~~
1 error generated.
make[2]: *** [samples/CMakeFiles/CPPStandardTest.dir/build.make:82: samples/CMakeFiles/CPPStandardTest.dir/CPPStandardTest.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:3322: samples/CMakeFiles/CPPStandardTest.dir/all] Error 2
make: *** [Makefile:171: all] Error 2
The terminal process "/usr/bin/bash '-c', 'make'" terminated with exit code: 2.

使用 sudo apt install各种下也没有解决头文件找不到的问题sob

Reply Favorite View the author
All Replies
joo
deepin
2022-06-29 15:39
#1

试试,安装这几个包看看,build-essential、libc6-dev、libgdbm-dev,这是debian(包括衍生)cmake需要的很基础的编译和调试的包

Reply View the author
fuuko
deepin
2022-06-29 16:34
#2

检查一下clang版本,看它是否支持C++20

Reply View the author
画卦伏羲
deepin
2022-06-29 18:24
#3
fuuko

检查一下clang版本,看它是否支持C++20

FuXii@FuXii-PC:~$ clang --version
Debian clang version 15.0.0-++20220622102607+46be5faaf034-1~exp1~20220622222616.569
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

版本是15.0.0的,应该是支持 c++20

这是官网的 c++20支持信息:

image.png

Reply View the author
画卦伏羲
deepin
2022-06-29 18:29
#4
joo

试试,安装这几个包看看,build-essential、libc6-dev、libgdbm-dev,这是debian(包括衍生)cmake需要的很基础的编译和调试的包

FuXii@FuXii-PC:~$ sudo apt install build-essential
Reading package lists... Done
Building dependency tree   
Reading state information... Done
build-essential is already the newest version (12.6).
0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.

FuXii@FuXii-PC:~$ sudo apt install libc6-dev
Reading package lists... Done
Building dependency tree   
Reading state information... Done
libc6-dev is already the newest version (2.28.19-1+dde).
libc6-dev set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.

FuXii@FuXii-PC:~$ sudo apt install libgbdm-dev
Reading package lists... Done
Building dependency tree   
Reading state information... Done
E: Unable to locate package libgbdm-dev

libgdbm-dev找不到

我感觉应该不是这几个库的问题sob

Reply View the author
joo
deepin
2022-06-29 18:31
#5

libgdbm-dev不重要可有可无

Reply View the author
画卦伏羲
deepin
2022-06-29 18:35
#6
joo

libgdbm-dev不重要可有可无

不行 基本上开发相关库都是最新的了 concepts头文件还是找不到,我全局搜也没搜到sob

Reply View the author
joo
deepin
2022-06-29 18:41
#7

我对clang不熟悉,帮不上忙,你可以去clang官方社区提问,这样更快捷。

比如我看到一些人的提问:Just as a side note: Clang 10 (libc++) doesn't implement maybe this implementation can be used instead: https://github.com/cjdb/cjdb-ranges
So even if we get Clang 10 in ndk r22 it might not be useful for concepts any time soon.

你去官方问问clang 15支持 concepts了未

Reply View the author
joo
deepin
2022-06-29 18:43
#8
画卦伏羲

不行 基本上开发相关库都是最新的了 concepts头文件还是找不到,我全局搜也没搜到sob

不重要就是,不用安装

Reply View the author
joo
deepin
2022-06-29 18:55
#9

我确认c20是支持concepts的,但如何配置,需要你自己去看官方文档,

Reply View the author
画卦伏羲
deepin
2022-06-29 19:09
#10
joo

我确认c20是支持concepts的,但如何配置,需要你自己去看官方文档,

已经去llvm的github提issue了

Reply View the author