Lors de l'activation de C++11 avec stdlibc++ 4.7, clang erreur, alors que gcc compile fine

J'ai essayé d'obtenir de C++11 au travail, après la navigation sur différents sites web et de Q/r, je suis toujours avoir des problèmes avec. Je veux utiliser clang avec libstdc++. Il est indiqué dans le cliquetis d'état qu'il est pris en charge avec patch - http://clang.llvm.org/libstdc++4.7-clang11.patch. J'ai télécharger le gcc4.7 de macports et fait des changements correspondants dans les en-têtes pour gcc4.7

La raison pour laquelle je n'utilise pas la libc++ est parce que ABI compatibilités entre libc++ ou libstdc++, indiqué par ce fil: Pourquoi ne peut-clang avec la libc++ en c++0x lien mode de ce coup de pouce::program_options exemple?

OK, après tout est fait, j'ai testé mon programme d'installation avec le code suivant:

#include <mutex>
#include <thread>

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

Je m'attends à ce que devrait inclure le travail en vertu de c++11.

Donc, voici comment je le compiler avec:
avec GCC

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

Compiler avec succès

avec Clang

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

J'obtiens cette erreur:

@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 <class _Tp>
^
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<typename _Tp>
^
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<typename _Tp, _Tp __v>
^
/opt/local/include/gcc47/c++/type_traits:65:11: error: unknown type name 'integral_constant'
typedef integral_constant<bool, true>     true_type;
^
/opt/local/include/gcc47/c++/type_traits:65:28: error: expected unqualified-id
typedef integral_constant<bool, true>     true_type;
^
/opt/local/include/gcc47/c++/type_traits:68:11: error: unknown type name 'integral_constant'
typedef integral_constant<bool, false>    false_type;
^
/opt/local/include/gcc47/c++/type_traits:68:28: error: expected unqualified-id
typedef integral_constant<bool, false>    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<bool, !_Pp::value>
^
/opt/local/include/gcc47/c++/type_traits:126:38: error: expected class name
: public integral_constant<bool, !_Pp::value>
^
/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<bool, (__is_void_helper<typename
^
/opt/local/include/gcc47/c++/type_traits:151:38: error: expected class name
: public integral_constant<bool, (__is_void_helper<typename
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.

Je suis en utilisant clang version:

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

Je fais quelque chose de mal? ou est-ce un clang problème avec la dernière version de gcc 4.7 libstc++?

Vous êtes explicitement -I-ing gcc-4.7-têtes internes dans un clang compiler, je ne m'attends pas à ce travail de discernement.
si je fais cela: j'ai aussi voir l'erreur. @work:boostTest$ clang++ -std=c++11 -L/opt/local/lib/gcc47 main.cpp -o principal.cpp:1:10: erreur fatale: mutex " fichier non trouvé #include <mutex> 1 erreur générée.
Avez-vous essayé en passant -std=c++11 -stdlib=libstdc++
juste essayé, il produit les mêmes résultats.
Quel système d'exploitation utilisez-vous ? Sur la plupart des Systèmes d'exploitation de Clang devriez être capable de trouver automatiquement la GCC en-têtes. Si ce n'est pas pour votre système d'exploitation, alors le pilote de la logique devrait être adapté.

OriginalL'auteur Negative Zero | 2012-04-25