Warning when using qint64 with PRIi64 on 64 bit linux
-
@DuBu Use ll instead of li, see http://www.cplusplus.com/reference/cstdio/printf/
-
I wonder what is wrong, the qint64 which is actually a long long int or the PRIi64 macro which is actually a "li"?
-
Hi @DuBu
Qt could fix it by defining
typedef int64_t qint64;
instead oftypedef long long qint64;
on Linux. But, of course, there could be some side effects of that change that I do not see. Maybe some supported compiler does not yet have theint64_t
type.-Michael.
-
Hi @DuBu
Qt could fix it by defining
typedef int64_t qint64;
instead oftypedef long long qint64;
on Linux. But, of course, there could be some side effects of that change that I do not see. Maybe some supported compiler does not yet have theint64_t
type.-Michael.
@m.sue long long is not necessarily always 64 bit. The length of integral types in C/C++ isn't specified exactly. The only thing specified is:
char <= short <= int <= long int <= long long
The exact size of each type depends on platform and compiler.
-
@m.sue long long is not necessarily always 64 bit. The length of integral types in C/C++ isn't specified exactly. The only thing specified is:
char <= short <= int <= long int <= long long
The exact size of each type depends on platform and compiler.
Hi @jsulm
Ok, but as
int64_t
is guarantueed to be 64-bit, it is not guarantueed to be defined for every compiler. So it's no good choice forqint64
.Nevertheless Qt should find a way to use it without warnings in printf with the new PRI macros, They are just about invented to use with
long long
s that are or are not 64-bit depending on the compiler/machine.-Michael.
-
Hi @jsulm
Ok, but as
int64_t
is guarantueed to be 64-bit, it is not guarantueed to be defined for every compiler. So it's no good choice forqint64
.Nevertheless Qt should find a way to use it without warnings in printf with the new PRI macros, They are just about invented to use with
long long
s that are or are not 64-bit depending on the compiler/machine.-Michael.
@m.sue Well, qint64 is guaranteed to be 64 bit, so you cannot use long long to typedef it.
int64_t is defined in C++11 and as Qt requires C++11 since quite some time it is perfectly valid to use int64_t in my opinion.
And why use printf in C++ at all? -
@m.sue Well, qint64 is guaranteed to be 64 bit, so you cannot use long long to typedef it.
int64_t is defined in C++11 and as Qt requires C++11 since quite some time it is perfectly valid to use int64_t in my opinion.
And why use printf in C++ at all?