我在运行ArchLinux的系统上使用clang
版本4.0.0,它一直运行良好,但最近我无法编译使用某些STL标头的程序了!Clang无法编译使用<functional>标题的程序
详细说明:输出的
clang --version
:
gcc --version
的
clang version 4.0.0 (tags/RELEASE_400/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
:
gcc (GCC) 7.1.1 20170528
实施例:
我试着编译如下琐碎的程序:
#include <functional>
int main()
{
return 0;
}
我使用下面的命令:
clang++ -std=c++1z test.cxx
,结果是失败的:
In file included from test.cxx:3:
In file included from /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.1.1/../../../../include/c++/7.1.1/functional:60:
In file included from /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.1.1/../../../../include/c++/7.1.1/unordered_map:47:
In file included from /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.1.1/../../../../include/c++/7.1.1/bits/hashtable.h:37:
In file included from /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.1.1/../../../../include/c++/7.1.1/bits/node_handle.h:39:
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.1.1/../../../../include/c++/7.1.1/optional:1032:27: error: use of
class template 'optional' requires template arguments
template <typename _Tp> optional(_Tp) -> optional<_Tp>;
^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.1.1/../../../../include/c++/7.1.1/optional:451:11: note: template
is declared here
class optional
^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.1.1/../../../../include/c++/7.1.1/optional:1032:40: error:
expected ';' at end of declaration
template <typename _Tp> optional(_Tp) -> optional<_Tp>;
^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.1.1/../../../../include/c++/7.1.1/optional:1032:41: error: cannot
use arrow operator on a type
template <typename _Tp> optional(_Tp) -> optional<_Tp>;
^
3 errors generated.
这是一个错误STL还是我的设置搞砸了?
您是否尝试过重新排列包含的顺序?这有时会导致我的程序。或者试试如果removìng'#include'和'#include '帮助或导致不同的错误 –
您似乎在使用gcc C++标准库。也许尝试使用叮当声。像'-stdlib = libC++'。 – juanchopanza
@ThFl我删除了除“”以外的所有其他标题,问题依然存在。我将编辑原始问题。不过谢谢。 –
nshct