[webkit-dev] Reminder: be careful when printing sized integer types
utatane.tea at gmail.com
Thu May 11 18:18:57 PDT 2017
Or, alternative way is casting the value to `unsigned long long` and always
using %llu for uint64_t.
uint64_t value = ...;
printf("%llu", (unsigned long long)value);
On Wed, May 10, 2017 at 4:07 AM, Michael Catanzaro <mcatanzaro at igalia.com>
> 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.
> webkit-dev mailing list
> webkit-dev at lists.webkit.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the webkit-dev