在OS X 10.8.5上使用Xcode 5.0和Qt 5.1.1构建问题

时间:2013-09-27 16:55:56

标签: c++ xcode qt c++11 qt5

我正在使用Xcode 4.x,Qt 5.0.1在OS X 10.8.5上构建可以很好地构建的代码,但我刚刚升级了Xcode和Qt,并且在拉入Qt头时我无法构建任何内容。

问题是QtSharedPointer类使用std :: forward但据我所知,OS X 10.8.5 / Xcode 5.0仍然不支持std :: forward。它没有在随附的标准库中的任何地方定义,因此,当我尝试构建时,我收到此错误:

In file included from .../Qt5.1.1/5.1.1/clang_64/lib/QtWidgets.framework/Headers/QAction:1:                                                          
In file included from .../Qt5.1.1/5.1.1/clang_64/lib/QtWidgets.framework/Headers/qaction.h:47:                                                       
In file included from .../Qt5.1.1/5.1.1/clang_64/lib/QtWidgets.framework/Headers/qwidget.h:49:                                                       
In file included from .../Qt5.1.1/5.1.1/clang_64/lib/QtGui.framework/Headers/qpalette.h:47:                                                          
In file included from .../Qt5.1.1/5.1.1/clang_64/lib/QtGui.framework/Headers/qbrush.h:53:                                                            
In file included from .../Qt5.1.1/5.1.1/clang_64/lib/QtGui.framework/Headers/qpixmap.h:49:                                                           
In file included from .../Qt5.1.1/5.1.1/clang_64/lib/QtCore.framework/Headers/qsharedpointer.h:50:                                                   
.../Qt5.1.1/5.1.1/clang_64/lib/QtCore.framework/Headers/qsharedpointer_impl.h:411:36: error: no template named 'forward' in namespace 'std'; did you mean 'boost::forward'?
        new (result.data()) T(std::forward<Args>(arguments)...);                                                                                     
                            ~~~~~^~~~~~~                                                                                                             
                            boost::forward                                                                                                           
/usr/local/include/boost/move/utility.hpp:176:21: note: 'boost::forward' declared here                                                               
        inline T&& forward(U&& t                                                                                                                     
                    ^                                                                                                                                

我确实注意到QtSharedPointer标题顶部的这些行:

#if defined(Q_COMPILER_RVALUE_REFS) && defined(Q_COMPILER_VARIADIC_TEMPLATES)                                                                            
#  include <utility>           // for std::forward                                                                                                       
#endif

但是在下面(第411行),它只使用std :: forward而不检查是否定义了这些宏

    // now initialize the data
    new (result.data()) T(std::forward<Args>(arguments)...);

这些宏实际上是未定义的,因此,我最初强制包含实用程序但是因为我后来发现std :: forward不在那里,所以它没有帮助。

这似乎是一个Qt错误,我打算在那里提交,但有没有人想出一个解决方法?

1 个答案:

答案 0 :(得分:1)

实际上,我意识到使用std :: forward的整个方法由另一个检查Q_COMPILER_RVALUE_REFS的ifdef保护。我只是编辑了QtCore.framework / Versions / 5 / Headers / qcompilerdetection.h并手动取消了Q_COMPILER_RVALUE_REFS,这让我得以建立。