Random C/C++ Snippets
Cross platform fixed size printing
In order to write cross platform code with fixed sizes you often have to deal with uint32_t and other fixed size vars.
But printing them in a cross platform manner is a PITA.
printf("%u", (uint32_t)x ); // will mismatch on x86_64Use inttypes instead.
<inttypes.h>
printf("%" PRIu32, (uint32_t)x );