Mark, you're right, MSVC supports %z for size_t (which is certainly preferred over the Microsoft-specific %I). This is supported at least since VS 2015 (https://docs.microsoft.com/en-us/cpp/c-runtime-library/format-specification-syntax-printf-and-wprintf-functions?view=vs-2015#size-prefixes-for-printf-and-wprintf-format-type-specifiers). But I'm not aware of a sane portable way of writing
int64_t i = 42; printf("Works on Windows only: %I64d\n", i);
other than
printf("Works on all C99-compatible platforms: %"PRId64"\n", i);
Sure the following works
printf("Works on all C99-compatible platforms: %lli\n", (long long)i);
but I always have to pull up the standard to be sure the type I'm casting to has sufficient size on all platforms. And it also requires C99.
Mark, you're right, MSVC supports %z for size_t (which is certainly preferred over the Microsoft-specific %I). This is supported at least since VS 2015 (https:/ /docs.microsoft .com/en- us/cpp/ c-runtime- library/ format- specification- syntax- printf- and-wprintf- functions? view=vs- 2015#size- prefixes- for-printf- and-wprintf- format- type-specifiers). But I'm not aware of a sane portable way of writing
int64_t i = 42;
printf("Works on Windows only: %I64d\n", i);
other than
printf("Works on all C99-compatible platforms: %"PRId64"\n", i);
Sure the following works
printf("Works on all C99-compatible platforms: %lli\n", (long long)i);
but I always have to pull up the standard to be sure the type I'm casting to has sufficient size on all platforms. And it also requires C99.