QDataStream >> uin64_t
-
Hello, I do have a function like this
void MainWindow::bttnClc() { uint64_t it3; QByteArray byte; QDataStream raw(&byte, QIODevice::ReadOnly); raw.setFloatingPointPrecision(QDataStream::DoublePrecision); raw.setByteOrder(QDataStream::ByteOrder::LittleEndian); raw.device()->seek(0); raw >> it3; }
It is just an example but when I try to compile it on WSL2 with cmake I get the given error
error: no match for ‘operator>>’ (operand types are ‘QDataStream’ and ‘uint64_t’ {aka ‘long unsigned int’})
When I looked over it I saw there is no uint implementation of >> in QDataStream.cpp.
MY question is why is this code works on Windows and not working on Linux, How to fix this error without changing the code or do I have to change the code?
Thank you for your time.
-
@Christian-Ehrlicher
What is the typical definition foruint64_t
, and where does it come from? How would it differ fromquint64
?qglobal.h:
msvc: typedef unsigned __int64 quint64; /* 64 bit unsigned /
other: typedef unsigned long long quint64; / 64 bit unsigned */cstdint or whereever the depths of the standard includes.
gcc: typedef unsigned long int __uint64_t;
typedef __uint64_t uint64_t;unsigned long long != unsigned long int I would guess.
-
Hello, I do have a function like this
void MainWindow::bttnClc() { uint64_t it3; QByteArray byte; QDataStream raw(&byte, QIODevice::ReadOnly); raw.setFloatingPointPrecision(QDataStream::DoublePrecision); raw.setByteOrder(QDataStream::ByteOrder::LittleEndian); raw.device()->seek(0); raw >> it3; }
It is just an example but when I try to compile it on WSL2 with cmake I get the given error
error: no match for ‘operator>>’ (operand types are ‘QDataStream’ and ‘uint64_t’ {aka ‘long unsigned int’})
When I looked over it I saw there is no uint implementation of >> in QDataStream.cpp.
MY question is why is this code works on Windows and not working on Linux, How to fix this error without changing the code or do I have to change the code?
Thank you for your time.
@ikuris
There is QDataStream &QDataStream::operator<<(quint64 i). And foruint64
https://doc.qt.io/qt-6/qtglobal.html#quint64-typedef definesTypedef for
unsigned long long int
. This type is guaranteed to be 64-bit on all platforms supported by Qt.Would have thought that would work. Might depend on compiler or platform. I note your error message says
‘uint64_t’ {aka ‘long unsigned int’}
which differs from
unsigned long long int
?Is
uint64_t
defined in a C++ standard library? I would investigate howuint64_t
is not the same asquint64
. And how‘uint64_t’ {aka ‘long unsigned int’}
does not match any of theQDataStream:operator<<
integer overloads? Actually, verify what happens in the WSL2 case withquint64
here? -
@ikuris
There is QDataStream &QDataStream::operator<<(quint64 i). And foruint64
https://doc.qt.io/qt-6/qtglobal.html#quint64-typedef definesTypedef for
unsigned long long int
. This type is guaranteed to be 64-bit on all platforms supported by Qt.Would have thought that would work. Might depend on compiler or platform. I note your error message says
‘uint64_t’ {aka ‘long unsigned int’}
which differs from
unsigned long long int
?Is
uint64_t
defined in a C++ standard library? I would investigate howuint64_t
is not the same asquint64
. And how‘uint64_t’ {aka ‘long unsigned int’}
does not match any of theQDataStream:operator<<
integer overloads? Actually, verify what happens in the WSL2 case withquint64
here?QDataStream has no overload for uint64_t, only for quint64.
-
QDataStream has no overload for uint64_t, only for quint64.
@Christian-Ehrlicher
What is the typical definition foruint64_t
, and where does it come from? How would it differ fromquint64
? -
@Christian-Ehrlicher
What is the typical definition foruint64_t
, and where does it come from? How would it differ fromquint64
?qglobal.h:
msvc: typedef unsigned __int64 quint64; /* 64 bit unsigned /
other: typedef unsigned long long quint64; / 64 bit unsigned */cstdint or whereever the depths of the standard includes.
gcc: typedef unsigned long int __uint64_t;
typedef __uint64_t uint64_t;unsigned long long != unsigned long int I would guess.
-
@ikuris
There is QDataStream &QDataStream::operator<<(quint64 i). And foruint64
https://doc.qt.io/qt-6/qtglobal.html#quint64-typedef definesTypedef for
unsigned long long int
. This type is guaranteed to be 64-bit on all platforms supported by Qt.Would have thought that would work. Might depend on compiler or platform. I note your error message says
‘uint64_t’ {aka ‘long unsigned int’}
which differs from
unsigned long long int
?Is
uint64_t
defined in a C++ standard library? I would investigate howuint64_t
is not the same asquint64
. And how‘uint64_t’ {aka ‘long unsigned int’}
does not match any of theQDataStream:operator<<
integer overloads? Actually, verify what happens in the WSL2 case withquint64
here? -
qglobal.h:
msvc: typedef unsigned __int64 quint64; /* 64 bit unsigned /
other: typedef unsigned long long quint64; / 64 bit unsigned */cstdint or whereever the depths of the standard includes.
gcc: typedef unsigned long int __uint64_t;
typedef __uint64_t uint64_t;unsigned long long != unsigned long int I would guess.
@Christian-Ehrlicher said in QDataStream >> uin64_t:
unsigned long long != unsigned long int
I would guess.Interesting.
-
So this is the reason why it does compile on Windows ? Thank you.
-
-
So this is the reason why it does compile on Windows ? Thank you.
@ikuris said in QDataStream >> uin64_t:
So this is the reason why it does compile on Windows
Already explained:
unsigned long long != unsigned long int