Hi all,
I use the following debug macro to quicly check variables values in code of interest:
#define dbs(x) qDebug(QVariant(x).toString().latin1())
I can write something like
dbs(5);
dbs("5");
int num = 5;
dbs(num);
dbs(str);
dbs(5);
dbs("5");
int num = 5;
dbs(num);
QString str("5");
dbs(str);
To copy to clipboard, switch view to plain text mode
and everything works as expected.
I have a problem with container's sizes that are size_t types.
As example:
QValueVector<int> v;
v.append(5);
dbs(v.count()); // gives an error on 64bit systems
QValueVector<int> v;
v.append(5);
dbs(v.count()); // gives an error on 64bit systems
To copy to clipboard, switch view to plain text mode
This is because size_t is an unsigned int 64 bits long and cannot be auto converted by compiler to int or uint types that are 32 bits and are the only constructors defined by QVariant for integral types.
How can do my macro work as expected? there exsist another way to write a macro with the same results.
I searched on the net with no results, so here I am asking for an help.
Thanks
Marco
Bookmarks