简体   繁体   English

使用MSVC 2013在Windows上构建Qt 5.7时出现编译错误

[英]Compile error when building qt 5.7 on Windows with msvc 2013

When I try to build the source code of Qt 5.7, I am getting the following compile error 当我尝试构建Qt 5.7的源代码时,出现以下编译错误

qnode_p.h(108): error C2955: 'Qt3DCore::QNodePrivate::DestructionFunction' : use of alias template requires template argument list qnode_p.h(108):错误C2955:'Qt3DCore :: QNodePrivate :: DestructionFunction':使用别名模板需要模板参数列表

qnode_p.h(105) : see declaration of 'Qt3DCore::QNodePrivate::DestructionFunction' qscene.cpp qnode_p.h(105):参见'Qt3DCore :: QNodePrivate :: DestructionFunction'的声明qscene.cpp

qnode_p.h(108) : error C2955: 'Qt3DCore::QNodePrivate::DestructionFun ction' : use of alias template requires template argument list qnode_p.h(108):错误C2955:'Qt3DCore :: QNodePrivate :: DestructionFunction':使用别名模板需要模板参数列表

qnode_p.h(105) : see declaration of 'Qt3DCore::QNodePrivate::DestructionFunction' Generating Code qnode_p.h(105):参见'Qt3DCore :: QNodePrivate :: DestructionFunction'生成代码的声明

It is error C2955 use of alias template requires template argument list. 错误C2955使用别名模板需要模板参数列表。

The source code that is causing the problem is below 导致该问题的源代码如下

class QT3DCORE_PRIVATE_EXPORT QNodePrivate : public QObjectPrivate, public    QObservableInterface
{
    public:
   QNodePrivate();
   ~QNodePrivate();
...
   template<typename Caller, typename NodeType>
   using DestructionFunction = void (Caller::*)(NodeType *);

   template<typename Caller, typename NodeType, typename PropertyType>
   void registerDestructionHelper(NodeType *, DestructionFunction<Caller, NodeType>, PropertyType);

   template<typename Caller, typename NodeType>
   void registerDestructionHelper(NodeType *node, DestructionFunction<Caller, NodeType> func, NodeType *&)
   {
      // If the node is destoyed, we make sure not to keep a dangling pointer to it
      auto f = std::bind(func, static_cast<Caller *>(q_func()), nullptr);
      m_destructionConnections.insert(node, QObject::connect(node, &QNode::nodeDestroyed, f));
   }

   template<typename Caller, typename NodeType>
   void registerDestructionHelper(NodeType *node, DestructionFunction<Caller, NodeType> func, QVector<NodeType*> &)
   {
      // If the node is destoyed, we make sure not to keep a dangling pointer to it
      auto f = std::bind(func, static_cast<Caller *>(q_func()), node);
      m_destructionConnections.insert(node, QObject::connect(node, &QNode::nodeDestroyed, f));
   }

   //....
}

line 105 is using 第105行正在使用

DestructionFunction = void (Caller::*)(NodeType *);

line 108 is 108行是

void registerDestructionHelper(NodeType *, DestructionFunction<Caller, NodeType>, PropertyType);

From what I read about C++11 this should compile ok but for some reason vs 2013 gives the above error. 从我读到的有关C ++ 11的内容来看,应该可以编译,但是由于某些原因,vs 2013会出现上述错误。

If it somebody help : 如果有人帮助:

Comment line 104 and 105: 评论行104和105:

// template<typename Caller, typename NodeType>
// using DestructionFunction = void (Caller::*)(NodeType *);

Change line 108 from: 将第108行更改为:

void registerDestructionHelper(NodeType *, DestructionFunction, PropertyType);

to: 至:

void registerDestructionHelper(NodeType *, void (Caller::*)(NodeType *), PropertyType);

line 111 from: 第111行来自:

void registerDestructionHelper(NodeType *node, DestructionFunction<Caller, NodeType> func, NodeType *&)

to : 至 :

void registerDestructionHelper(NodeType *node, void (Caller::*func)(NodeType *), NodeType *&)

line 119 from: 第119行来自:

void registerDestructionHelper(NodeType *node, DestructionFunction<Caller, NodeType> func, QVector<NodeType*> &)

to : 至 :

void registerDestructionHelper(NodeType *node, void (Caller::*func)(NodeType *), QVector<NodeType*> &)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM