c++ - qlist.h(466):错误 C2061:语法错误:标识符“n”
问题描述
我在我的一个项目中包含 Qt 库时遇到问题。包括:
#include <QtCore/QString>
#include <QtXml/QDomDocument>
#include <iostream>
#pragma push_macro("realloc")
#undef realloc
#include <QtCore/QFile>
#include <QtCore/QFileInfo>
#include <QtCore/QDir>
#pragma pop_macro("realloc")
包括 QFile
, QFileInfo
并 QDir
导致此错误:
C:\qt\5.15.0\msvc2019_64\include\QtCore\qlist.h(466): error C2061: syntax error: identifier 'n'
C:\qt\5.15.0\msvc2019_64\include\QtCore\qlist.h(464): note: while compiling class template member function 'void QList<QString>::node_construct(QList<QString>::Node *,const T &)'
with
[
T=QString
]
C:\qt\5.15.0\msvc2019_64\include\QtCore\qlist.h(625): note: see reference to function template instantiation 'void QList<QString>::node_construct(QList<QString>::Node *,const T &)' being compiled
with
[
T=QString
]
C:\qt\5.15.0\msvc2019_64\include\QtCore\qlist.h(854): note: while compiling class template member function 'QList<QString>::QList(const QList<QString> &)'
C:\qt\5.15.0\msvc2019_64\include\QtCore\qstringlist.h(117): note: see reference to function template instantiation 'QList<QString>::QList(const QList<QString> &)' being compiled
C:\qt\5.15.0\msvc2019_64\include\QtCore\qstringlist.h(112): note: see reference to class template instantiation 'QList<QString>' being compiled
C:\qt\5.15.0\msvc2019_64\include\QtCore\qlist.h(505): error C2061: syntax error: identifier 'current'
C:\qt\5.15.0\msvc2019_64\include\QtCore\qlist.h(487): note: while compiling class template member function 'void QList<QString>::node_copy(QList<QString>::Node *,QList<QString>::Node *,QList<QString>::Node *)'
C:\qt\5.15.0\msvc2019_64\include\QtCore\qlist.h(860): note: see reference to function template instantiation 'void QList<QString>::node_copy(QList<QString>::Node *,QList<QString>::Node *,QList<QString>::Node *)' being compiled
使用 push/pop 宏是因为与 realloc 模板类似的错误,此处已解决:Qt: not enough arguments for function-like macro invocation 'realloc', qvector.h。
解决方案
推荐阅读
- julia - 在 Julia 中绘制图表中的奇怪日期
- c++ - 如果我只在列表中存储非零元素,如何将两个矩阵相乘
- >>?
- python - matplotlib:为什么我的多色线图忽略了边界值?
- r - JAGS 递归模型
- python - {% include %} 标签不出现 Django
- discord - 如何从每个服务器中的用户中删除角色?不和谐.py
- javascript - 我如何检查“HH:mm:ss”中的时间是上午还是下午?
- r - 使用 yaml 动态重新编码并将字段附加到数据帧/小标题
- dns - DDD:我可以从 UI 设计开始设计我的领域吗?
- c# - C# CRUD 与 Access 数据库:无法执行交互(不是有效的文件名)