【发布时间】:2014-05-30 19:45:24
【问题描述】:
我有以下代码:
#include <type_traits>
int main()
{
}
g++ 文件.cc -std=c++0x
工作得很好。
但是,由于某种原因,我需要使用 clang++。
当我尝试时
clang++ file.cc -std=c++0x
我收到一堆错误:
In file included from file.cc:1:
In file included from /usr/include/c++/4.4.4/type_traits:50:
/usr/include/c++/4.4.4/tr1_impl/type_traits:230:41: error: expected ')'
struct is_function<_Res(_ArgTypes......)>
^
/usr/include/c++/4.4.4/tr1_impl/type_traits:230:28: note: to match this '('
struct is_function<_Res(_ArgTypes......)>
^
/usr/include/c++/4.4.4/tr1_impl/type_traits:230:12: error: redefinition of 'is_function<type-parameter-0-0 (type-parameter-0-1, ...)>'
struct is_function<_Res(_ArgTypes......)>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/4.4.4/tr1_impl/type_traits:227:12: note: previous definition is here
struct is_function<_Res(_ArgTypes...)>
^
/usr/include/c++/4.4.4/tr1_impl/type_traits:233:29: error: type qualifier is not allowed on this function
struct is_function<_Res(_ArgTypes...) const>
....
clang++ --version 给出:
clang version 2.8 (branches/release_28)
Target: x86_64-redhat-linux-gnu
Thread model: posix
任何想法如何解决这个问题? (-std=c++11 不起作用,无法识别。)
【问题讨论】:
-
我建议升级 Clang。
-
@chris 不是我的服务器...有什么办法可以使用当前版本?虽然我会要求升级它,但可能需要一些时间。
-
你必须在你的 main 中添加一个 return 语句
-
@Bruno,根据 C++ 的每个 ISO 标准,你不知道。
-
@kloop 您的 clang 版本太旧了。请参阅我之前关于 TR1 的评论,除了升级编译器之外,这可能是您唯一的选择