Search code examples
cprintftypedefstdint

Is there a way to fix format specifiers warnings for stdint types?


The problem is that on one platform (windows, mvsc2015) uint64_t is defined as unsigned long long and on another (ubuntu, clang) it's unsigned long and there is the code which looks like sprintf(buffer, "%#llx", u64key);


Solution

  • The solution is to use C99's format macros, in particular PRIu64 for an uint64_t:

    #include <inttypes.h>
    …
    sprintf(buffer, "%#" PRIu64 "\n", u64key);