Random C/C++ Snippets
date: 2018-03-15
author: Peterino
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_64
Use inttypes instead.
<inttypes.h>
printf("%" PRIu32, (uint32_t)x );
Menu