Qt:没有足够的参数用于类似函数的宏调用“realloc”,qvector.h

问题描述

我遇到了一个问题,在我的项目中包含了一些 QtCore 库。我正在使用 CMake 和 Visual Studio Qt 5.15。在我的 CMakeLists.txt 中,我像这样包含 QtCore:

find_package(Qt5 REQUIRED COMPONENTS Core)

target_link_libraries(${projectName} PRIVATE Qt5::Core)

然后我在我的代码中添加 #include <QtCore/qvector.h> 并且会出现一些错误:

C:\qt\5.15.0\msvc2019_64\include\QtCore\qvector.h(103): warning C4003: not enough arguments for function-like macro invocation 'realloc'
C:\qt\5.15.0\msvc2019_64\include\QtCore\qvector.h(316): error C2059: syntax error: 'constant'
C:\qt\5.15.0\msvc2019_64\include\QtCore\qvector.h(327): note: see reference to class template instantiation 'QVector<T>' being compiled
C:\qt\5.15.0\msvc2019_64\include\QtCore\qvector.h(411): warning C4003: not enough arguments for function-like macro invocation 'realloc'
C:\qt\5.15.0\msvc2019_64\include\QtCore\qvector.h(420): warning C4003: not enough arguments for function-like macro invocation 'realloc'
C:\qt\5.15.0\msvc2019_64\include\QtCore\qvector.h(700): error C2988: unrecognizable template declaration/definition
C:\qt\5.15.0\msvc2019_64\include\QtCore\qvector.h(700): error C2059: syntax error: 'constant'
C:\qt\5.15.0\msvc2019_64\include\QtCore\qvector.h(1071): warning C4003: not enough arguments for function-like macro invocation 'realloc'

即使我只包含 <QtCore/QFileInfo><QtCore/QDir>,也会出现此错误。但是当我包含 <QtCore/QString><QtXml/QDomDocument> 时,不会出现此错误。

我尝试删除 CMake 缓存,但没有结果。自从从 Visual Studio 解决方案迁移到 CMake 后,这个问题就开始了。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...