M
Max Laier
What should a compiler on a 64bit platform do with the following:
unit64_t x=1234567;
printf("%llu", x);
On 32Bit unit64_t is usually a macro for "unsigned long long" so above
example is perfectly right.
On 64Bit unit64_t is usually a macro for "unsigned long" so above code might
cause a warning.
Of course you can use PRIu64 to avoid that, but many docs on printf tell
you:
"The optional character sequence ll, specifying that a following d, i, o, u,
x, or X conversion corresponds to a **quad** int or unsigned **quad** int
argument, or that a following n conversion corresponds to a pointer to a
quad int argument. The use of q has been deprecated as conversion
character."
A quad, however, is 64bit on every platform and hence %llu should print
uint64_t without a warning.
What do you think? Is this right or wrong?
What is the real meaning of %llu:
- print a "long long" variable?
- or print a 64bit varibale?
Regards
Max
unit64_t x=1234567;
printf("%llu", x);
On 32Bit unit64_t is usually a macro for "unsigned long long" so above
example is perfectly right.
On 64Bit unit64_t is usually a macro for "unsigned long" so above code might
cause a warning.
Of course you can use PRIu64 to avoid that, but many docs on printf tell
you:
"The optional character sequence ll, specifying that a following d, i, o, u,
x, or X conversion corresponds to a **quad** int or unsigned **quad** int
argument, or that a following n conversion corresponds to a pointer to a
quad int argument. The use of q has been deprecated as conversion
character."
A quad, however, is 64bit on every platform and hence %llu should print
uint64_t without a warning.
What do you think? Is this right or wrong?
What is the real meaning of %llu:
- print a "long long" variable?
- or print a 64bit varibale?
Regards
Max