Correctly print uint64_t / size_t in C

Have you even stumbled upon a strange warning when trying to print an uint64_t or a size_t ?
Do no take that warning lightly, as your code can break anytime if you’re not fixing it.

Warning example:

warning: format '%llu' expects argument of type 'long long unsigned int', but argument 4 has type 'uint64_t' [-Wformat]

To avoid the warning and crashes, you have to use a one of the PRIxxx macro which will choose the right way for your system to print the value, without crashes.

#include <inttypes.h>
uint64_t i;
printf("%"PRIu64"\n", i);

Macros for printf family can be found here.