-
Notifications
You must be signed in to change notification settings - Fork 213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix -Wformat / -Wformat-non-iso on MinGW UCRT #874
Fix -Wformat / -Wformat-non-iso on MinGW UCRT #874
Conversation
apps/shared/avifutil.h
Outdated
// | ||
// 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)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to use UCRT with Visual Studio before 2013? Otherwise it can be "simplified" to:
#if (defined(_MSVC) && _MSVC < 1800) || (defined(__USE_MINGW_ANSI_STDIO) && __USE_MINGW_ANSI_STDIO == 0 && !defined(_UCRT))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
VS <= 2013 never use UCRT and VS >= 2015 always use UCRT.
However, I find this expression easier to understand:
we want a feature in the C runtime.
- UCRT definitely provides it.
- msvcr120 (the version of msvcrt Visual Studio 2013 uses) provides it, but no macro can be used to test CRT version so test Visual Studio version instead.
- MinGW sometimes provides it by patch and we can test if the patch is applied.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Yuan,
It is reasonable to require Visual Studio 2015 or later today. For example, libaom requires Visual Studio 2017 or later:
https://aomedia.googlesource.com/aom/+/master/README.md#microsoft-visual-studio-builds
Let's drop support for Visual Studio 2013 or older. Could you simplify this expression?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
81e7cdf
to
ac431a6
Compare
Edit: scratch that, sorry... I now see |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I edited the comment slightly.
// Additionally, with c99 set as the standard mingw-w64 toolchains built with | ||
// the commit mentioned can patch format functions to support the %z specifier, | ||
// even it's using the old msvcrt, and this can be detected by | ||
// even if it's using the old msvcrt, and this can be detected by |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tongyuantongyu Yuan: I added "if" after "even". I am less certain about this change. Please check it. Thanks.
MinGW can be configured to use UCRT, which is the new C runtime library for Windows. I'm moving my MinGW dev environment to the UCRT variant.
UCRT supports
"%zu"
properly so MinGW didn't patch*printf
functions and set__USE_MINGW_ANSI_STDIO
to 1. This makesAVIF_FMT_ZU
defined to"%Iu"
, and triggers warning from GCC and Clang.Detect UCRT by check
_UCRT
macro, which MSSVC and MinGW both defines, and use"%zu"
when using UCRT.