Error with toULong() in Windows Qt 6.5.1
-
Hi Everyone.
My first post, hopefully I am in the correct spot.
bool ok;
QString mStr = "FD17B9DD1653D9DF";
quint64 tmp = mStr.toULong(&ok,16);This works in Linux ... ok = true, and tmp is the 64bit number representation of the hex characters.
In windows 10 (x64) this fails - but if I use toULongLong it works.
I was under the impression toULong should attempt to convert to a 64 bit unsigned integer in both Ubuntu x86_64 and Windows 10 (x64) or am I wrong?
Ant
-
Hi Everyone.
My first post, hopefully I am in the correct spot.
bool ok;
QString mStr = "FD17B9DD1653D9DF";
quint64 tmp = mStr.toULong(&ok,16);This works in Linux ... ok = true, and tmp is the 64bit number representation of the hex characters.
In windows 10 (x64) this fails - but if I use toULongLong it works.
I was under the impression toULong should attempt to convert to a 64 bit unsigned integer in both Ubuntu x86_64 and Windows 10 (x64) or am I wrong?
Ant
@Anthony_NZ said in Error with toULong() in Windows Qt 6.5.1:
I was under the impression toULong should attempt to convert to a 64 bit unsigned integer in both Ubuntu x86_64 and Windows 10 (x64) or am I wrong?
You're wrong and could have proven it by yourself easily:
std::cout << "sizeof(ulong): " << sizeof(unsigned long) << "\n"; std::cout << "sizeof(ulonglong): " << sizeof(unsigned long long) << "\n";
Linux 64 bit:
sizeof(ulong): 8
sizeof(ulonglong): 8Windows 64bit:
sizeof(ulong): 4
sizeof(ulonglong): 8 -
@Anthony_NZ said in Error with toULong() in Windows Qt 6.5.1:
I was under the impression toULong should attempt to convert to a 64 bit unsigned integer in both Ubuntu x86_64 and Windows 10 (x64) or am I wrong?
You're wrong and could have proven it by yourself easily:
std::cout << "sizeof(ulong): " << sizeof(unsigned long) << "\n"; std::cout << "sizeof(ulonglong): " << sizeof(unsigned long long) << "\n";
Linux 64 bit:
sizeof(ulong): 8
sizeof(ulonglong): 8Windows 64bit:
sizeof(ulong): 4
sizeof(ulonglong): 8Newbie error - thank you. I didn't appreciate Microsoft Windows backwards compatiblity if LP64 and LLP64 as I normally exclusively live on linux systems.
Thank you!
-
Newbie error - thank you. I didn't appreciate Microsoft Windows backwards compatiblity if LP64 and LLP64 as I normally exclusively live on linux systems.
Thank you!
That's why Qt introduced the qt fixed integer types by themself. the toULong() stuff is an relict from old Qt times and imho should have been replaced a long time ago with functions returning fixed integer types (or the qt fixed integer types).