Solved Problem with qmap.h from QT5.6.3 for MSVC2013 (64bit)
-
My app builds fine with QT5.6.3 using msvc2013 (64bit).
Get this error:
C:\Qt\5.6.3\msvc2013_64\include\QtCore/qmap.h(226) : error C2059: syntax error : '&'
C:\Qt\5.6.3\msvc2013_64\include\QtCore/qmap.h(222) : while compiling class template member function 'QMapNode<Key,T> *QMapData<Key,T>::createNode(const Key &,const T &,QMapNode<Key,T> *,bool)'
with
[
Key=QString
, T=QVariant
]
C:\Qt\5.6.3\msvc2013_64\include\QtCore/qmap.h(798) : see reference to function template instantiation 'QMapNode<Key,T> *QMapData<Key,T>::createNode(const Key &,const T &,QMapNode<Key,T> *,bool)' being compiled
with
[
Key=QString
, T=QVariant
]
C:\Qt\5.6.3\msvc2013_64\include\QtCore/qmap.h(326) : see reference to class template instantiation 'QMapData<Key,T>' being compiled
with
[
Key=QString
, T=QVariant
]
C:\Qt\5.6.3\msvc2013_64\include\QtCore/qmap.h(326) : while compiling class template member function 'QMap<QString,QVariant>::QMap(void) throw()'
C:\Qt\5.6.3\msvc2013_64\include\QtCore/qvariant.h(789) : see reference to function template instantiation 'QMap<QString,QVariant>::QMap(void) throw()' being compiled
C:\Qt\5.6.3\msvc2013_64\include\QtCore/qvariant.h(500) : see reference to class template instantiation 'QMap<QString,QVariant>' being compiled
C:\Qt\5.6.3\msvc2013_64\include\QtCore/qmap.h(226) : error C2143: syntax error : missing ';' before ')'
C:\Qt\5.6.3\msvc2013_64\include\QtCore/qmap.h(228) : error C2059: syntax error : '&'
C:\Qt\5.6.3\msvc2013_64\include\QtCore/qmap.h(228) : error C2143: syntax error : missing ';' before ')'
C:\Qt\5.6.3\msvc2013_64\include\QtCore/qmap.h(226) : error C2059: syntax error : '&'
C:\Qt\5.6.3\msvc2013_64\include\QtCore/qmap.h(222) : while compiling class template member function 'QMapNode<Key,T> *QMapData<Key,T>::createNode(const Key &,const T &,QMapNode<Key,T> *,bool)'
with
[
Key=QString
, T=QVariant
]
C:\Qt\5.6.3\msvc2013_64\include\QtCore/qmap.h(798) : see reference to function template instantiation 'QMapNode<Key,T> *QMapData<Key,T>::createNode(const Key &,const T &,QMapNode<Key,T> *,bool)' being compiled
with
[
Key=QString
, T=QVariant
]
C:\Qt\5.6.3\msvc2013_64\include\QtCore/qmap.h(326) : see reference to class template instantiation 'QMapData<Key,T>' being compiled
with
[
Key=QString
, T=QVariant
]
C:\Qt\5.6.3\msvc2013_64\include\QtCore/qmap.h(326) : while compiling class template member function 'QMap<QString,QVariant>::QMap(void) throw()'
C:\Qt\5.6.3\msvc2013_64\include\QtCore/qmap.h(226) : error C2143: syntax error : missing ';' before ')'
C:\Qt\5.6.3\msvc2013_64\include\QtCore/qmap.h(228) : error C2059: syntax error : '&'
C:\Qt\5.6.3\msvc2013_64\include\QtCore/qmap.h(228) : error C2143: syntax error : missing ';' before ')'
c:\qt\5.6.3\msvc2013_64\include\qtcore\qmap.h(226) : error C2059: syntax error : '&'
c:\qt\5.6.3\msvc2013_64\include\qtcore\qmap.h(222) : while compiling class template member function 'QMapNode<Key,T> *QMapData<Key,T>::createNode(const Key &,const T &,QMapNode<Key,T> *,bool)'
with
[
Key=QString
, T=QVariant
]
c:\qt\5.6.3\msvc2013_64\include\qtcore\qmap.h(798) : see reference to function template instantiation 'QMapNode<Key,T> *QMapData<Key,T>::createNode(const Key &,const T &,QMapNode<Key,T> *,bool)' being compiled
with
[
Key=QString
, T=QVariant
]
c:\qt\5.6.3\msvc2013_64\include\qtcore\qmap.h(326) : see reference to class template instantiation 'QMapData<Key,T>' being compiled
with
[
Key=QString
, T=QVariant
]
c:\qt\5.6.3\msvc2013_64\include\qtcore\qmap.h(326) : while compiling class template member function 'QMap<QString,QVariant>::QMap(void) throw()'
c:\qt\5.6.3\msvc2013_64\include\qtcore\qvariant.h(789) : see reference to function template instantiation 'QMap<QString,QVariant>::QMap(void) throw()' being compiled
c:\qt\5.6.3\msvc2013_64\include\qtcore\qvariant.h(500) : see reference to class template instantiation 'QMap<QString,QVariant>' being compiled
c:\qt\5.6.3\msvc2013_64\include\qtcore\qmap.h(226) : error C2143: syntax error : missing ';' before ')'
c:\qt\5.6.3\msvc2013_64\include\qtcore\qmap.h(228) : error C2059: syntax error : '&'
c:\qt\5.6.3\msvc2013_64\include\qtcore\qmap.h(228) : error C2143: syntax error : missing ';' before ')'PLEASE HELP ME!!! Do you know what the problem is? can I solve?
-
I solved!
the problem was of the macro:
#ifdef _DEBUG
#define new DEBUG_NEW
#endifthis macro only works if compiled under the Visual Studio development environment in DEBUG mode.
just change the macro in:#ifdef QT_DEBUG
#endifand add in .pro file:
CONFIG(debug, release|debug):DEFINES += QT_DEBUG
and Hola works with this macro under the Qt Creator development environment in DEBUG mode
-
Hi and welcome to devnet,
How are you using QMap ?
-
@SGaist Trank you,
excuse my ignorance in what sense how am I using QMap?if I understand correctly I'm using it in various ways in various sources:
- QMap<int,QString> ....
- QMap<int,int> ....
- QMap<int,RoleData> ....
RoleData is a class where they contain a series of parameters to be assigned one of the complex one there is also the parameter of type QVector<QString>
if that was what he wanted to know how I'm using QMap, then what problem can it be?
-
I would try to create a simple main which just instantiates a QMap instance to see if this works. I'm not really sure if Qt5 64bit with msvc2013 ever worked but it's rather old so I might be wrong.
-
I tried with various versions of Qt, the problem persists !! I do not understand what you're from ... do you think it's badly instanced?
does anyone know the solution to this problem?
-
Do you mean that you have the same problem with something like:
#include <QMap> #include <QString> #include <QtDebug> int main(int /*argc*/, char **/*argv*/) { QMap<int, QString> map; map[1] = QStringLiteral("test"); qDebug() << map; return 0; }
[edit: Fixed includes SGaist]
-
Did you include
QString
and theQVariant
headers? Please provide the snippet which induces this error. -
Sorry for the delay.
I tried with codes from as you indicated below QT5.6 with MSVC2013 64bit and it works.
the error that brings me back to my code gives it to me when I compile in Debug mode while in Release mode it works, only I need it in Debug mode to do analysis in Debbugers.
I do not understand why it gives me error in Debug mode and not in Release mode. in your opinion what can be wrong with Debug about QMap ??
-
@Domenico Check the includes @kshegunov mentioned. Most likely that's the problem.
-
Thank you so much for the solution !!
I tried as you said, including QString and QVariant in headers where it is using QMap .. the error persists .. :(
-
@Domenico can you post the files /classes where you use QMap and the error occurs?
-
I try to publish the sources, as it is too long. public part .h e .cpp where and how is using QMap, I hope it is understandable. if it is not, please let me know that I will try to publish more.
in the class .h
#ifndef ROLEADMINISTRATIONMODEL_H
#define ROLEADMINISTRATIONMODEL_H#include <QMap>
#include <QString>
#include <QVariant>
#include <QList>#include "ErrorTypeDefinition.h"
#include "RoleData.h"
#include "DBManager.h"class RoleAdministrationModel
{
private:
RoleData m_currentRoleSelected;
QMap<int,RoleData> m_roleList;RoleAdminErrorType deleteRole(RoleData roleData); RoleAdminErrorType modifyRole(RoleData roleData); RoleAdminErrorType newRole(RoleData roleData);
public:
RoleAdministrationModel();
QList<QString> getFuncList();
QList<RoleData> getRoleData();void roleSelected(RoleData rolSel); RoleAdminErrorType saveRole(RoleData role);
};
#endif // ROLEADMINISTRATIONMODEL_H
in the class .cpp
#include "RoleAdministrationModel.h"
RoleAdministrationModel::RoleAdministrationModel()
{
m_roleList.clear();
}QList<QString> RoleAdministrationModel::getFuncList()
{
return DBManager::getInstance()->getFuncList();
}QList<RoleData> RoleAdministrationModel::getRoleData()
{
QList<RoleData> roleList;
QList<RoleData>::iterator it;m_roleList.clear(); roleList = DBManager::getInstance()->getRoleData(); for(it = roleList.begin(); it != roleList.end(); it++) { m_roleList.insert((*it).getRoleId(),*it); } return roleList;
}
void RoleAdministrationModel::roleSelected(RoleData rolSel)
{
m_currentRoleSelected = rolSel;
}RoleAdminErrorType RoleAdministrationModel::deleteRole(RoleData roleData)
{
...not use QMap...
}RoleAdminErrorType RoleAdministrationModel::modifyRole(RoleData roleData)
{
...not use QMap...
}RoleAdminErrorType RoleAdministrationModel::newRole(RoleData roleData)
{
...not use QMap...
}RoleAdminErrorType RoleAdministrationModel::saveRole(RoleData role)
{
...not use QMap...
}this is class of Roledata.h
#ifndef ROLEDATA_H
#define ROLEDATA_H#include <QString>
#include <QVector>#include "EnumTypeDefinition.h"
class RoleData
{
public:
RoleData();
RoleData(int roleId,QString roleName,RoleOperationType op);
RoleData(QString roleName);
RoleData(int roleId,QString roleName);
QString getRoleName();
RoleOperationType getOperationType();
int getRoleId();
void addFuncionality(QString name);
QVector<QString> getFuncionalityList();
bool isValid();
bool isFuncIsAssociatedToRole(QString funcName);private:
int m_RoleId;
QString m_RoleName;
QVector<QString> m_FunctionalityNameList;
RoleOperationType m_Operation;
};Roledata.cpp
#include "RoleData.h"
RoleData::RoleData()
{
m_RoleName = "";
m_Operation = R_INVALID_OPERATION;
m_FunctionalityNameList.clear();
m_RoleId = -1;
}RoleData::RoleData(int roleId, QString roleName, RoleOperationType op)
{
m_RoleName = roleName;
m_Operation = op;
m_RoleId = roleId;
}RoleData::RoleData(QString roleName)
{
m_RoleName = roleName;
m_Operation = R_INVALID_OPERATION;
m_RoleId = -1;
}RoleData::RoleData(int roleId, QString roleName)
{
m_RoleId = roleId;
m_RoleName = roleName;
}QString RoleData::getRoleName()
{
return m_RoleName;
}RoleOperationType RoleData::getOperationType()
{
return m_Operation;
}int RoleData::getRoleId()
{
return m_RoleId;
}void RoleData::addFuncionality(QString name)
{
m_FunctionalityNameList.append(name);
}QVector<QString> RoleData::getFuncionalityList()
{
return m_FunctionalityNameList;
}bool RoleData::isValid()
{
return !(m_RoleName.isEmpty());
}bool RoleData::isFuncIsAssociatedToRole(QString funcName)
{
bool result = false;result = m_FunctionalityNameList.contains(funcName); return result;
}
the error that brings me back into Debug mode:
while the other QMap I'm using (QMap <int, String> and QMap <int, int>) I do not publish it because it's too long, but I think the error comes more from code as indicated above, according to you if something wrong with code above? if everything is perfect I try to publish the codes that are using QMap <int, QString> and QMap <int, int>.
thank you very much for those who give me a solution !!!
-
@Domenico And what is in EnumTypeDefinition.h ?
-
you're right, sorry, the class of EnumTypeDefinition.h is
#ifndef ENUMTYPEDEFINITION_H
#define ENUMTYPEDEFINITION_Htypedef enum _UserAccountOperationType
{
UAC_NEW_USER = 0,
UAC_MODIFY_USER,
UAC_DELETE_USER,
UAC_INVALID_OPERATION}UserAccountOperationType;
typedef enum _RoleOperationType
{
R_NEW_ROLE = 0,
R_MODIFY_ROLE,
R_DELETE_ROLE,
R_INVALID_OPERATION}RoleOperationType;
typedef enum _ObjectSensitivity
{
OS_UNSENSIBLE,
OS_SENSIBLE}ObjectSensitivity;
typedef enum _ObjectActDeact
{
OAD_ACTIVE,
OAD_DEACTIVE}ObjectActDeact;
typedef enum _SystemStatus
{
SS_UNKNOWN,
SS_READY,
SS_DEFAULT,
SS_OFFLINE,
SS_ACTIVE,
SS_CONFIG,
SS_FAILURE,
SS_DEGRADED}SystemStatus;
#endif // ENUMTYPEDEFINITION_H
what do you think of the codes above?
-
The only place where you actually use QMap is here
QList<RoleData> RoleAdministrationModel::getRoleData() { QList<RoleData> roleList; QList<RoleData>::iterator it; m_roleList.clear(); roleList = DBManager::getInstance()->getRoleData(); for(it = roleList.begin(); it != roleList.end(); it++) { m_roleList.insert((*it).getRoleId(),*it); } return roleList; }
which doesn't seem quite right, I'm unsure.
Can you try it with a more simplified version?
QList<RoleData> RoleAdministrationModel::getRoleData() { QList<RoleData> roleList = DBManager::getInstance()->getRoleData(); m_roleList.clear(); for(const RoleData &data : roleList) { m_roleList.insert(data.getRoleId(), data); } return roleList; }
-
I have done a deep study the problem of the error does not concern in the codes .. but the error comes from the macro of the _DEBUG in fact compile in RELEASE mode works while compiling in DEBUG mode gives me error as indicated above, then going to look at the macro:
#ifdef _DEBUG
#define new DEBUG_NEW
#endifthis macro of _DEBUG does not convince me the error I think it is connected to this macro .. someone can define a macro that can fill in the right way under Qt5.6 with MSVC2013 64bit without giving errors on qmap.h and qlist.h ??
Thanks again
-
I solved!
the problem was of the macro:
#ifdef _DEBUG
#define new DEBUG_NEW
#endifthis macro only works if compiled under the Visual Studio development environment in DEBUG mode.
just change the macro in:#ifdef QT_DEBUG
#endifand add in .pro file:
CONFIG(debug, release|debug):DEFINES += QT_DEBUG
and Hola works with this macro under the Qt Creator development environment in DEBUG mode