2012-12-06 14 views
9

C++ 11とlibC++を有効にすると、単純なhello worldでもclangでコンパイルすることができません。たとえば、次のコードlibC++とC++ 11とのコマンドラインからのclangの使い方mac os x

#include <iostream> 

int main() 
{ 
    std::cout << "Hello, World!" << std::endl; 
    return 0; 
} 

は、私は、コードは、私はXcodeのを使用する場合は罰金コンパイルとlibcのためのオプション++とC++ 11を設定しますclang++ -std=c++11 -stdlib=libc++ main.cpp

In file included from main.cpp:1: 
In file included from /usr/bin/../lib/c++/v1/iostream:38: 
In file included from /usr/bin/../lib/c++/v1/ios:216: 
In file included from /usr/bin/../lib/c++/v1/__locale:15: 
In file included from /usr/bin/../lib/c++/v1/string:434: 
In file included from /usr/bin/../lib/c++/v1/algorithm:591: 
/usr/bin/../lib/c++/v1/type_traits:165:12: error: unknown type name 
     '_LIBCPP_CONSTEXPR' 
    static _LIBCPP_CONSTEXPR const _Tp  value = __v; 
     ^
/usr/bin/../lib/c++/v1/type_traits:165:30: error: expected member name or ';' 
     after declaration specifiers 
    static _LIBCPP_CONSTEXPR const _Tp  value = __v; 
    ~~~~~~~~~~~~~~~~~~~~~~~~^
/usr/bin/../lib/c++/v1/type_traits:169:9: error: unknown type name 
     '_LIBCPP_CONSTEXPR' 
     _LIBCPP_CONSTEXPR operator value_type() const {return value;} 
     ^
/usr/bin/../lib/c++/v1/type_traits:169:63: error: use of undeclared identifier 
     'value' 
     _LIBCPP_CONSTEXPR operator value_type() const {return value;} 
                  ^
/usr/bin/../lib/c++/v1/type_traits:173:1: error: unknown type name 
     '_LIBCPP_CONSTEXPR' 
_LIBCPP_CONSTEXPR const _Tp integral_constant<_Tp, __v>::value; 
^ 
/usr/bin/../lib/c++/v1/type_traits:173:19: error: expected unqualified-id 
_LIBCPP_CONSTEXPR const _Tp integral_constant<_Tp, __v>::value; 
       ^
/usr/bin/../lib/c++/v1/type_traits:730:2: error: is_base_of not implemented. 
#error is_base_of not implemented. 
^ 
/usr/bin/../lib/c++/v1/type_traits:400:56: error: no member named 'value' in 
     'std::__1::is_integral<void>' 
    : public integral_constant<bool, is_integral<_Tp>::value  || 
            ~~~~~~~~~~~~~~~~~~^ 
/usr/bin/../lib/c++/v1/type_traits:941:19: note: in instantiation of template 
     class 'std::__1::is_arithmetic<void>' requested here 
       (is_arithmetic<_A2>::value || is_void<_A2>::value) && 
       ^
/usr/bin/../lib/c++/v1/type_traits:949:22: note: in instantiation of default 
     argument for '__promote<type-parameter-0-0, void, void>' required here 
    typedef typename __promote<_A1>::type __type1; 
        ^~~~~~~~~~~~~~ 
/usr/bin/../lib/c++/v1/type_traits:949:38: error: expected a qualified name 
     after 'typename' 
    typedef typename __promote<_A1>::type __type1; 
            ^
/usr/bin/../lib/c++/v1/type_traits:949:42: error: expected ';' at end of 
     declaration list 
    typedef typename __promote<_A1>::type __type1; 
             ^
/usr/bin/../lib/c++/v1/type_traits:941:39: error: no member named 'value' in 
     'std::__1::is_arithmetic<void>' 
       (is_arithmetic<_A2>::value || is_void<_A2>::value) && 
        ~~~~~~~~~~~~~~~~~~~~^ 
/usr/bin/../lib/c++/v1/type_traits:950:22: note: in instantiation of default 
     argument for '__promote<type-parameter-0-1, void, void>' required here 
    typedef typename __promote<_A2>::type __type2; 
        ^~~~~~~~~~~~~~ 
/usr/bin/../lib/c++/v1/type_traits:950:38: error: expected a qualified name 
     after 'typename' 
    typedef typename __promote<_A2>::type __type2; 
            ^
/usr/bin/../lib/c++/v1/type_traits:950:42: error: expected ';' at end of 
     declaration list 
    typedef typename __promote<_A2>::type __type2; 
             ^
/usr/bin/../lib/c++/v1/type_traits:941:39: error: no member named 'value' in 
     'std::__1::is_arithmetic<void>' 
       (is_arithmetic<_A2>::value || is_void<_A2>::value) && 
        ~~~~~~~~~~~~~~~~~~~~^ 
/usr/bin/../lib/c++/v1/type_traits:951:38: error: expected a qualified name 
     after 'typename' 
    typedef typename __promote<_A3>::type __type3; 
            ^
/usr/bin/../lib/c++/v1/type_traits:951:42: error: expected ';' at end of 
     declaration list 
    typedef typename __promote<_A3>::type __type3; 
             ^
/usr/bin/../lib/c++/v1/type_traits:953:22: error: use of undeclared identifier 
     '__type1' 
    typedef decltype(__type1() + __type2() + __type3()) type; 
        ^
/usr/bin/../lib/c++/v1/type_traits:953:34: error: use of undeclared identifier 
     '__type2' 
    typedef decltype(__type1() + __type2() + __type3()) type; 
           ^
/usr/bin/../lib/c++/v1/type_traits:953:46: error: use of undeclared identifier 
     '__type3' 
    typedef decltype(__type1() + __type2() + __type3()) type; 
              ^
fatal error: too many errors emitted, stopping now [-ferror-limit=] 
20 errors generated. 

を実行すると、コンパイルから、次の出力を生成しますサポート。

ありがとうございます。

+0

「clang ++ -v」とは何ですか? –

+0

'Apple clangバージョン4.0(タグ/ Apple/clang-421.0.60)(LLVM 3.1svnベース) 対象:x86_64-apple-darwin11.4.2 スレッドモデル:posix' –

+0

Clang 4.0は古くなっています。 4.1が必要です。 Xcodeのどのバージョンをインストールしましたか? –

答えて

14

コマンドラインツールが古くなっています。 Clang 4.0はXcode 4.4に同梱されています。 Xcode 4.5に同梱されているClang 4.1が必要です。 Xcodeをインストールしたら、Preferencesウィンドウに行き、DownloadsペインとComponentsタブを選択し、 "Command Line Tools"のエントリがあります。右側に「インストール」というボタンが表示されます。

enter image description here

関連する問題