What is the format specifier to print a value of type std::uint64_t (from <cstdint>) using functions from the std::printf() family in C++?
C99 has PRIu64 (from <inttypes.h>) but it's not entirely clear to me that PRIu64 is valid C++11, although I could find hints that it may be.
Without PRIu64, and as far as I can tell, there's no single format specifier that will work in all cases:
- On 32-bit platforms,
std::uint64_tis going to be defined asunsigned long longand the format specifier will be%llu. - On 64-bit platforms,
std::uint64_tis going to be defined asunsigned longand the format specifier will be%lu. - However with Visual Studio,
%lluworks in both cases.