[Development] Using Qt 5 with C++11/Clang 3.1?

Stephen Chu stephen at ju-ju.com
Fri Jul 6 17:17:15 CEST 2012


Has anyone successfully build Qt 5 to use with Clang 3.1 on any 
platform? I see the new macx-clang-libc++ mkspecs are now included. 
Using it enables automatic detection of C++11 features in configure. But 
that causes errors on C++11 features when building like:

animation/qabstractanimation.cpp:215:1: error: initialization of 
non-aggregate type
       'QBasicAtomicPointer<QThreadStorage<QUnifiedTimer *> >' with an 
initializer list
Q_GLOBAL_STATIC(QThreadStorage<QUnifiedTimer *>, unifiedTimer)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Qt/5.0/qtbase/src/corelib/../../include/QtCore/../../src/corelib/global/qglobal.h:768:33: 
note:
       expanded from macro 'Q_GLOBAL_STATIC'
                             = { Q_BASIC_ATOMIC_INITIALIZER(0), false }; 
       \
                                 ^
/Qt/5.0/qtbase/src/corelib/../../include/QtCore/../../src/corelib/thread/qbasicatomic.h:256:41: 
note:
       expanded from macro 'Q_BASIC_ATOMIC_INITIALIZER'
#  define Q_BASIC_ATOMIC_INITIALIZER(a) { (a) }
                                         ^~~~~~~
I can get it sort of built by configuring with -no-c++11 option. It 
still fails to build some of the libraries but it's enough for my simple 
project. But the same errors (and constexpr ones I reported before) show 
up whenever -std=c++11 and moc is involved.

GCC 4.7 seems to be able to compile those fine but I read that it's 
actually bugs in the compiler. And we are stuck with 4.2 on OS X anyways.



More information about the Development mailing list