为什么不clang ++编译以下代码?

时间:2014-05-30 19:45:25

标签: c++ linux c++11

我有以下代码:

#include <type_traits>

int main()
{
}

g ++ file.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不起作用,无法识别。)

1 个答案:

答案 0 :(得分:3)

Clang 2.8不支持C ++ 11功能,您需要升级编译器才能使用它们。

相关问题