【问题标题】:Compile error when building qt 5.7 on Windows with msvc 2013使用 msvc 2013 在 Windows 上构建 qt 5.7 时出现编译错误
【发布时间】:2017-02-06 21:25:05
【问题描述】:

当我尝试构建 Qt 5.7 的源代码时,我收到以下编译错误

qnode_p.h(108):错误 C2955: 'Qt3DCore::QNodePrivate::DestructionFunction' : 使用别名模板 需要模板参数列表

qnode_p.h(105) : 见声明 'Qt3DCore::QNodePrivate::DestructionFunction' qscene.cpp

qnode_p.h(108) : 错误 C2955: 'Qt3DCore::QNodePrivate::DestructionFun ction' : 使用别名模板需要模板参数列表

qnode_p.h(105) : 见声明 'Qt3DCore::QNodePrivate::DestructionFunction' 生成代码

错误 C2955 使用别名模板需要模板参数列表。

导致问题的源代码如下

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));
   }

   //....
}

第 105 行正在使用

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

第 108 行是

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

从我读到的关于 C++11 的内容来看,这应该可以编译,但由于某种原因 vs 2013 给出了上述错误。

【问题讨论】:

  • 我会编辑你的问题。但对于以后的帖子,只添加错误中有意义的部分。
  • 不建议新手自己构建Qt。
  • Qt 5.7 需要具有 good C++11/14 支持的现代编译器(VS2013 不支持)。使用 VS2015 更新 3 重试 :-)
  • @ddriver 我不明白为什么不这样做。这并不复杂,使用相同的编译器构建所有应用程序和依赖库是一件的事情(防止一些错误)。
  • 有 MSVC2013 和 MSVC2015 的预构建版本。所以它应该工作。自己构建它没有什么意义 - 在慢速机器上需要几个小时,并且可能会失败。仅在您确实需要时才构建 Qt,例如,我使用静态 64 位 MinGW 构建,我别无选择,只能自己构建,因为 Qt 不提供预构建的。

标签: c++ qt templates c++11


【解决方案1】:

如果有人帮忙:

注释行 104 和 105:

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

将第 108 行更改为:

void registerDestructionHelper(NodeType *, DestructionFunction, PropertyType);

到:

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

第 111 行来自:

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

到:

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

第 119 行来自:

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

到:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-05-30
    • 1970-01-01
    • 1970-01-01
    • 2019-10-10
    • 2016-11-20
    • 1970-01-01
    • 1970-01-01
    • 2021-01-20
    相关资源
    最近更新 更多