[webkit-dev] Reminder: be careful when printing sized integer types
Michael Catanzaro
mcatanzaro at igalia.com
Tue May 9 12:07:41 PDT 2017
Hi,
This is just a reminder to avoid a case that occasionally causes
warnings for GTK+. On Mac, uint64_t is (I assume) a typedef for
unsigned long long. But on Linux 86_64 it's a typedef for unsigned
long. This means they have to be printed differently. Using "%llu" to
print a uint64_t (presumably) works on Mac, but it causes compiler
warnings on Linux. The right way is unfortunately to use "%" PRIu64,
which expands to "%llu" on Mac and "%lu" on Linux. There are variants
on these macros for many different integer types:
http://en.cppreference.com/w/cpp/types/integer
It's verbose, but helps us avoid warnings. And since it's declared in
stdint.h/cstdint, if you're using uint64_t then it's already available.
Thanks,
Michael
More information about the webkit-dev
mailing list