При включении C++11 с stdlibc++ 4.7 выдается ошибка clang, в то время как gcc компилируется нормально

Я пытался заставить C++11 работать после просмотра различных веб-сайтов и ответов на вопросы, но у меня все еще возникают проблемы. Я хочу использовать clang с libstdС++. В статусе clang указано, что поддерживается патчем -http://clang.llvm.org/libstdc++4.7-clang11.patch. Я загружаю gcc4.7 с macports и делаю соответствующие изменения в заголовках для gcc4.7

Причина, по которой я не использую libc++, заключается в том, что совместимость ABI между libc++ и libstdc++ указана в этой теме:Почему можно& #39; t clang с libc++ в режиме c++0x связать этот пример опций программы boost ::_?

ОК, после того, как все сделано, я проверил свою установку с помощью следующего кода:

#include 
#include 

int main ( ) {
    std::mutex myMutext;
    return 0;
}

Я ожидаю, что включение должно работать в C++11.

Итак, вот как я скомпилирую его с помощью :с GCC

g++ -std=c++11 -I/opt/local/include/gcc47/c++ -L/opt/local/lib/gcc47 main.cpp -o main

Успешная компиляция

с Clang

clang++ -std=c++11 -I/opt/local/include/gcc47/c++ -L/opt/local/lib/gcc47 main.cpp -o main

Я получаю эту ошибку:

@work:boostTest$ clang++ -std=c++11 -I/opt/local/include/gcc47/c++ -L/opt/local/lib/gcc47 main.cpp -o main
In file included from main.cpp:1:
In file included from /opt/local/include/gcc47/c++/mutex:38:
In file included from /opt/local/include/gcc47/c++/tuple:37:
In file included from /opt/local/include/gcc47/c++/utility:70:
/opt/local/include/gcc47/c++/bits/stl_relops.h:72:3: error: unknown type name '_GLIBCXX_BEGIN_NAMESPACE_VERSION'
  _GLIBCXX_BEGIN_NAMESPACE_VERSION
  ^
/opt/local/include/gcc47/c++/bits/stl_relops.h:86:5: error: expected unqualified-id
    template 
    ^
In file included from main.cpp:1:
In file included from /opt/local/include/gcc47/c++/mutex:38:
In file included from /opt/local/include/gcc47/c++/tuple:37:
In file included from /opt/local/include/gcc47/c++/utility:71:
In file included from /opt/local/include/gcc47/c++/bits/stl_pair.h:61:
/opt/local/include/gcc47/c++/bits/move.h:38:1: error: unknown type name '_GLIBCXX_BEGIN_NAMESPACE_VERSION'
_GLIBCXX_BEGIN_NAMESPACE_VERSION
^
/opt/local/include/gcc47/c++/bits/move.h:45:3: error: expected unqualified-id
  template
  ^
In file included from main.cpp:1:
In file included from /opt/local/include/gcc47/c++/mutex:38:
In file included from /opt/local/include/gcc47/c++/tuple:37:
In file included from /opt/local/include/gcc47/c++/utility:71:
In file included from /opt/local/include/gcc47/c++/bits/stl_pair.h:61:
In file included from /opt/local/include/gcc47/c++/bits/move.h:57:
/opt/local/include/gcc47/c++/type_traits:41:1: error: unknown type name '_GLIBCXX_BEGIN_NAMESPACE_VERSION'
_GLIBCXX_BEGIN_NAMESPACE_VERSION
^
/opt/local/include/gcc47/c++/type_traits:55:3: error: expected unqualified-id
  template
  ^
/opt/local/include/gcc47/c++/type_traits:65:11: error: unknown type name 'integral_constant'
  typedef integral_constant     true_type;
          ^
/opt/local/include/gcc47/c++/type_traits:65:28: error: expected unqualified-id
  typedef integral_constant     true_type;
                           ^
/opt/local/include/gcc47/c++/type_traits:68:11: error: unknown type name 'integral_constant'
  typedef integral_constant    false_type;
          ^
/opt/local/include/gcc47/c++/type_traits:68:28: error: expected unqualified-id
  typedef integral_constant    false_type;
                           ^
/opt/local/include/gcc47/c++/type_traits:71:36: error: expected ';' after top level declarator
    constexpr _Tp integral_constant<_Tp, __v>::value;
                                   ^
/opt/local/include/gcc47/c++/type_traits:83:14: error: expected class name
    : public false_type
             ^
/opt/local/include/gcc47/c++/type_traits:106:14: error: expected class name
    : public true_type
             ^
/opt/local/include/gcc47/c++/type_traits:126:14: error: unknown template name 'integral_constant'
    : public integral_constant
             ^
/opt/local/include/gcc47/c++/type_traits:126:38: error: expected class name
    : public integral_constant
                                     ^
/opt/local/include/gcc47/c++/type_traits:142:14: error: expected class name
    : public false_type { };
             ^
/opt/local/include/gcc47/c++/type_traits:146:14: error: expected class name
    : public true_type { };
             ^
/opt/local/include/gcc47/c++/type_traits:151:14: error: unknown template name 'integral_constant'
    : public integral_constant

Я использую версию clang:

Apple clang version 4.0 (tags/Apple/clang-418.2.41) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin11.3.0
Thread model: posix

Я делаю что-то не так? или это проблема с лязгом в последней версии gcc 4.7 libstc++?

9
задан Community 23 May 2017 в 11:45
поделиться