diff --git a/apps/shared/avifutil.h b/apps/shared/avifutil.h index 79e1f3c8f0..42669fbde4 100644 --- a/apps/shared/avifutil.h +++ b/apps/shared/avifutil.h @@ -6,14 +6,18 @@ #include "avif/avif.h" -// The %z format specifier is not available with Visual Studios before 2013 and mingw-w64 toolchains -// with `__USE_MINGW_ANSI_STDIO` not set to 1. Hence the %I format specifier must be used instead -// to print out `size_t`. Newer Visual Studios and mingw-w64 toolchains built with the commit -// mentioned with c99 set as the standard supports the %z specifier properly. +// The %z format specifier is not available in old version of msvcrt, which is +// used by Visual Studios before 2013 and usually mingw-w64 toolchains. +// Hence the %I format specifier must be used instead to print out `size_t`. +// Visual Studio from 2015 uses UCRT, which supports the %z specifier properly; +// mingw-w64 toolchains can also be configured to use UCRT. +// Additionally, with c99 set as the standard mingw-w64 toolchains built with +// the commit mentioned can patch format functions to support the %z specifier, +// and this can be detected by `__USE_MINGW_ANSI_STDIO` macro. // // Related mingw-w64 commit: bfd33f6c0ec5e652cc9911857dd1492ece8d8383 -#if (defined(_MSVC) && _MSVC < 1800) || (defined(__USE_MINGW_ANSI_STDIO) && __USE_MINGW_ANSI_STDIO == 0) +#if !defined(_UCRT) && ((defined(_MSVC) && _MSVC < 1800) || (defined(__USE_MINGW_ANSI_STDIO) && __USE_MINGW_ANSI_STDIO == 0)) #define AVIF_FMT_ZU "%Iu" #else #define AVIF_FMT_ZU "%zu"