【问题标题】:qvector.h(74) : error C2182: 't' : illegal use of type 'void'qvector.h(74) : 错误 C2182: 't' : 非法使用类型 'void'
【发布时间】:2015-04-13 16:37:59
【问题描述】:

我从 Qt 的网站下载了 5.2.1 版本,上面写着可以与 mscv2012_64_opengl 一起使用。

在我决定使用公共语言运行时支持/clr 选项之前,它运行良好。我这样做是因为我使用了一个 .dll,它充当 C++ 和我在 C# 中的一些代码之间的包装。

当我构建项目时,我收到以下错误

C:\Qt\Qt5.2.1\5.2.1\msvc2012_64_opengl\include\QtCore/qvector.h(74): error C2182: 't' : illegal use of type 'void'
1>          c:\qt\qt5.2.1\5.2.1\msvc2012_64_opengl\include\qtcore\qmap.h(119) : see reference to class template instantiation 'QVector<T>' being compiled
1>          with
1>          [
1>              T=void
1>          ]
1>          C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xmemory0(903) : see reference to function template instantiation 'void std::allocator_traits<_Alloc>::construct<_Ty,_Ty>(std::allocator<_Ty> &,_Objty *,_V0_t &&)' being compiled
1>          with
1>          [
1>              _Alloc=std::allocator<DataColumn_3D>,
1>              _Ty=DataColumn_3D,
1>              _Objty=DataColumn_3D,
1>              _V0_t=DataColumn_3D
1>          ]
1>          C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xmemory0(903) : see reference to function template instantiation 'void std::allocator_traits<_Alloc>::construct<_Ty,_Ty>(std::allocator<_Ty> &,_Objty *,_V0_t &&)' being compiled
1>          with
1>          [
1>              _Alloc=std::allocator<DataColumn_3D>,
1>              _Ty=DataColumn_3D,
1>              _Objty=DataColumn_3D,
1>              _V0_t=DataColumn_3D
1>          ]
1>          C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xmemory(433) : see reference to function template instantiation 'void std::_Wrap_alloc<_Alloc>::construct<DataColumn_3D,_Valty>(_Ty *,_V0_t &&)' being compiled
1>          with
1>          [
1>              _Alloc=std::allocator<DataColumn_3D>,
1>              _Valty=DataColumn_3D,
1>              _Ty=DataColumn_3D,
1>              _V0_t=DataColumn_3D
1>          ]
1>          C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xmemory(433) : see reference to function template instantiation 'void std::_Wrap_alloc<_Alloc>::construct<DataColumn_3D,_Valty>(_Ty *,_V0_t &&)' being compiled
1>          with
1>          [
1>              _Alloc=std::allocator<DataColumn_3D>,
1>              _Valty=DataColumn_3D,
1>              _Ty=DataColumn_3D,
1>              _V0_t=DataColumn_3D
1>          ]
1>          C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xmemory(473) : see reference to function template instantiation '_FwdIt std::_Uninit_move<_InIt,_FwdIt,std::allocator<_Ty>,DataColumn_3D>(_InIt,_InIt,_FwdIt,std::_Wrap_alloc<_Alloc> &,_Valty *,std::_Nonscalar_ptr_iterator_tag)' being compiled
1>          with
1>          [
1>              _FwdIt=DataColumn_3D *,
1>              _InIt=DataColumn_3D *,
1>              _Ty=DataColumn_3D,
1>              _Alloc=std::allocator<DataColumn_3D>,
1>              _Valty=DataColumn_3D
1>          ]
1>          C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\vector(1561) : see reference to function template instantiation '_FwdIt std::_Uninitialized_move<_Iter,DataColumn_3D*,std::_Wrap_alloc<_Alloc>>(_InIt,_InIt,_FwdIt,std::_Wrap_alloc<_Alloc> &)' being compiled
1>          with
1>          [
1>              _FwdIt=DataColumn_3D *,
1>              _Iter=DataColumn_3D *,
1>              _Alloc=std::allocator<DataColumn_3D>,
1>              _InIt=DataColumn_3D *
1>          ]
1>          C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\vector(1504) : see reference to function template instantiation 'DataColumn_3D *std::vector<_Ty>::_Umove<DataColumn_3D*>(_Iter,_Iter,DataColumn_3D *)' being compiled
1>          with
1>          [
1>              _Ty=DataColumn_3D,
1>              _Iter=DataColumn_3D *
1>          ]
1>          C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\vector(1504) : see reference to function template instantiation 'DataColumn_3D *std::vector<_Ty>::_Umove<DataColumn_3D*>(_Iter,_Iter,DataColumn_3D *)' being compiled
1>          with
1>          [
1>              _Ty=DataColumn_3D,
1>              _Iter=DataColumn_3D *
1>          ]
1>          C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\vector(1500) : while compiling class template member function 'void std::vector<_Ty>::_Reallocate(unsigned __int64)'
1>          with
1>          [
1>              _Ty=DataColumn_3D
1>          ]
1>          C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\vector(961) : see reference to function template instantiation 'void std::vector<_Ty>::_Reallocate(unsigned __int64)' being compiled
1>          with
1>          [
1>              _Ty=DataColumn_3D
1>          ]
1>          DataSource.cpp(256) : see reference to class template instantiation 'std::vector<_Ty>' being compiled
1>          with
1>          [
1>              _Ty=DataColumn_3D
1>          ]
1>C:\Qt\Qt5.2.1\5.2.1\msvc2012_64_opengl\include\QtCore/qvector.h(133): error C2182: 'at' : illegal use of type 'void'
1>C:\Qt\Qt5.2.1\5.2.1\msvc2012_64_opengl\include\QtCore/qvector.h(134): error C2182: '[]' : illegal use of type 'void'
1>C:\Qt\Qt5.2.1\5.2.1\msvc2012_64_opengl\include\QtCore/qvector.h(135): error C2182: '[]' : illegal use of type 'void'
1>C:\Qt\Qt5.2.1\5.2.1\msvc2012_64_opengl\include\QtCore/qvector.h(136): error C2182: 't' : illegal use of type 'void'
1>C:\Qt\Qt5.2.1\5.2.1\msvc2012_64_opengl\include\QtCore/qvector.h(137): error C2182: 't' : illegal use of type 'void'
1>C:\Qt\Qt5.2.1\5.2.1\msvc2012_64_opengl\include\QtCore/qvector.h(138): error C2182: 't' : illegal use of type 'void'
1>C:\Qt\Qt5.2.1\5.2.1\msvc2012_64_opengl\include\QtCore/qvector.h(139): error C2182: 't' : illegal use of type 'void'
1>C:\Qt\Qt5.2.1\5.2.1\msvc2012_64_opengl\include\QtCore/qvector.h(140): error C2182: 't' : illegal use of type 'void'
1>C:\Qt\Qt5.2.1\5.2.1\msvc2012_64_opengl\include\QtCore/qvector.h(148): error C2182: 't' : illegal use of type 'void'
1>C:\Qt\Qt5.2.1\5.2.1\msvc2012_64_opengl\include\QtCore/qvector.h(150): error C2182: 't' : illegal use of type 'void'
1>C:\Qt\Qt5.2.1\5.2.1\msvc2012_64_opengl\include\QtCore/qvector.h(151): error C2182: 't' : illegal use of type 'void'
1>C:\Qt\Qt5.2.1\5.2.1\msvc2012_64_opengl\include\QtCore/qvector.h(152): error C2182: 't' : illegal use of type 'void'
1>C:\Qt\Qt5.2.1\5.2.1\msvc2012_64_opengl\include\QtCore/qvector.h(153): error C2182: 't' : illegal use of type 'void'
1>C:\Qt\Qt5.2.1\5.2.1\msvc2012_64_opengl\include\QtCore/qvector.h(182): error C2182: 'x' : illegal use of type 'void'
1>C:\Qt\Qt5.2.1\5.2.1\msvc2012_64_opengl\include\QtCore/qvector.h(183): error C2182: 'x' : illegal use of type 'void'
1>C:\Qt\Qt5.2.1\5.2.1\msvc2012_64_opengl\include\QtCore/qvector.h(189): error C2182: 'first' : illegal use of type 'void'
1>C:\Qt\Qt5.2.1\5.2.1\msvc2012_64_opengl\include\QtCore/qvector.h(190): error C2182: 'first' : illegal use of type 'void'
1>C:\Qt\Qt5.2.1\5.2.1\msvc2012_64_opengl\include\QtCore/qvector.h(191): error C2182: 'last' : illegal use of type 'void'
1>C:\Qt\Qt5.2.1\5.2.1\msvc2012_64_opengl\include\QtCore/qvector.h(192): error C2182: 'last' : illegal use of type 'void'
1>C:\Qt\Qt5.2.1\5.2.1\msvc2012_64_opengl\include\QtCore/qvector.h(193): error C2182: 't' : illegal use of type 'void'
1>C:\Qt\Qt5.2.1\5.2.1\msvc2012_64_opengl\include\QtCore/qvector.h(194): error C2182: 't' : illegal use of type 'void'
1>C:\Qt\Qt5.2.1\5.2.1\msvc2012_64_opengl\include\QtCore/qvector.h(198): error C2182: 'defaultValue' : illegal use of type 'void'
1>C:\Qt\Qt5.2.1\5.2.1\msvc2012_64_opengl\include\QtCore/qvector.h(204): error C2182: 'reference' : illegal use of type 'void'
1>C:\Qt\Qt5.2.1\5.2.1\msvc2012_64_opengl\include\QtCore/qvector.h(205): error C2182: 'const_reference' : illegal use of type 'void'
1>C:\Qt\Qt5.2.1\5.2.1\msvc2012_64_opengl\include\QtCore/qvector.h(210): error C2182: 't' : illegal use of type 'void'
1>C:\Qt\Qt5.2.1\5.2.1\msvc2012_64_opengl\include\QtCore/qvector.h(211): error C2182: 't' : illegal use of type 'void'
1>C:\Qt\Qt5.2.1\5.2.1\msvc2012_64_opengl\include\QtCore/qvector.h(216): error C2182: 'front' : illegal use of type 'void'
1>C:\Qt\Qt5.2.1\5.2.1\msvc2012_64_opengl\include\QtCore/qvector.h(225): error C2182: 't' : illegal use of type 'void'
1>C:\Qt\Qt5.2.1\5.2.1\msvc2012_64_opengl\include\QtCore/qvector.h(227): error C2182: 't' : illegal use of type 'void'

这里有人知道如何解决这个问题吗?

【问题讨论】:

  • 转到您的项目属性并在配置属性的常规部分确保设置公共语言运行时支持 clr,我还假设您已经使用 Visual Studio 构建了 qt
  • @decoherence 我自己没有用 VS2012 构建 qt,我是从 Qt 的网站下载的。在配置属性中公共语言运行时支持设置为clr
  • @BRabbit27 你必须自己构建它
  • @PeterDuniho 不知道 c# 是如何进入标签的,对此感到抱歉。我编辑了帖子。
  • 关注doc.qt.io/qt-5/windows-building.html,它为我解决了过去的问题

标签: c++ qt visual-studio-2012


【解决方案1】:

来自常见问题:

Is there any way to compile the Qt source code and Qt applications with /clr flag?

我们不支持直接使用 CLR 构建 Qt 或 Qt 应用程序。要集成现有组件,您可以使用Active Qt 框架,它允许在 Qt 应用程序中集成 Active X 和 COM 对象。

【讨论】:

  • @Dimitry Sokolov Active Qt 的链接已损坏。 This one 工作。
【解决方案2】:

尝试以下操作,将 &lt;QtXXX&gt; 替换为您的模块。

#pragma unmanaged
#include <QtXXX>
#pragma managed

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-01-02
    • 2012-08-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多