Hi everybody,
following problem:
I'm using a struct comparable to this one in my code:
#ifndef STRUCT_MYPOINT
#define STRUCT_MYPOINT
#include <QDataStream>
typedef struct MyPoint {
int x;
int y;
}MyPoint;
{
out << (qint32)p.x;
out << (qint32)p.y;
return out;
}
{
in >> (qint32)p.x;
in >> (qint32)p.y;
return in;
}
#endif
#ifndef STRUCT_MYPOINT
#define STRUCT_MYPOINT
#include <QDataStream>
typedef struct MyPoint {
int x;
int y;
}MyPoint;
QDataStream &operator<<(QDataStream &out, const MyPoint &p)
{
out << (qint32)p.x;
out << (qint32)p.y;
return out;
}
QDataStream &operator>>(QDataStream &in, MyPoint &p)
{
in >> (qint32)p.x;
in >> (qint32)p.y;
return in;
}
#endif
To copy to clipboard, switch view to plain text mode
this struct is defined in a seperate *.h file, lets say "mypoint.h"
my code works fine if I compile it with Visual Studio .Net & Qt 4.4.0
now I also try to compile my code under a linux environment using qt 4.4.0 and gcc 4.2.0
now the same code won't compile anymore.
I get a long list of errors messages, with the important ones saying
no match for 'operator>>'
no match for 'operator<<'
searched the net for some kind of solution, but haven't found one.
only thing I learned is that I must add, at least, the following lines to my code:
friend Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const MyPoint &);
friend Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, MyPoint &);
To copy to clipboard, switch view to plain text mode
added these lines to my struct:
#ifndef STRUCT_MYPOINT
#define STRUCT_MYPOINT
#include <QDataStream>
typedef struct MyPoint {
int x;
int y;
}MyPoint;
{
out << (qint32)p.x;
out << (qint32)p.y;
return out;
}
{
in >> (qint32)p.x;
in >> (qint32)p.y;
return in;
}
#endif
#ifndef STRUCT_MYPOINT
#define STRUCT_MYPOINT
#include <QDataStream>
typedef struct MyPoint {
int x;
int y;
}MyPoint;
QDataStream &operator<<(QDataStream &out, const MyPoint &p)
{
out << (qint32)p.x;
out << (qint32)p.y;
return out;
}
QDataStream &operator>>(QDataStream &in, MyPoint &p)
{
in >> (qint32)p.x;
in >> (qint32)p.y;
return in;
}
friend Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const MyPoint &);
friend Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, MyPoint &);
#endif
To copy to clipboard, switch view to plain text mode
but the problem remains.
So what am I missing/doing wrong???
greetz
darksaga
Bookmarks