-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
build: make CURL_FORMAT_CURL_OFF_T[U]
work with mingw-w64 <=7.0.0
#14640
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vszakats
force-pushed
the
tests-client-mingw-printf
branch
from
August 21, 2024 22:45
a5e0d19
to
1c1a963
Compare
Example do not yet use `CURL_FORMAT_CURL_OFF_T[U]`, but they might in the future.
Here's an untested alternative plan: --- a/include/curl/system.h
+++ b/include/curl/system.h
@@ -178,10 +178,16 @@
# define CURL_TYPEOF_CURL_SOCKLEN_T int
#elif defined(__MINGW32__)
+# include <_mingw.h>
# include <inttypes.h>
# define CURL_TYPEOF_CURL_OFF_T long long
+#if defined(__MINGW64_VERSION_MAJOR) && __MINGW64_VERSION_MAJOR <= 7
+# define CURL_FORMAT_CURL_OFF_T "lld"
+# define CURL_FORMAT_CURL_OFF_TU "llu"
+#else
# define CURL_FORMAT_CURL_OFF_T PRId64
# define CURL_FORMAT_CURL_OFF_TU PRIu64
+#endif
# define CURL_SUFFIX_CURL_OFF_T LL
# define CURL_SUFFIX_CURL_OFF_TU ULL
# define CURL_TYPEOF_CURL_SOCKLEN_T int
--- a/lib/curl_setup.h
+++ b/lib/curl_setup.h
@@ -317,17 +317,6 @@
#define CURL_CONC_MACROS_(A,B) A ## B
#define CURL_CONC_MACROS(A,B) CURL_CONC_MACROS_(A,B)
-/* curl uses its own printf() function internally. It understands the GNU
- * format. Use this format, so that is matches the GNU format attribute we
- * use with the MinGW compiler, allowing it to verify them at compile-time.
- */
-#ifdef __MINGW32__
-# undef CURL_FORMAT_CURL_OFF_T
-# undef CURL_FORMAT_CURL_OFF_TU
-# define CURL_FORMAT_CURL_OFF_T "lld"
-# define CURL_FORMAT_CURL_OFF_TU "llu"
-#endif
-
/* based on logic in "curl/mprintf.h" */
#if (defined(__GNUC__) || defined(__clang__) || \ |
bagder
reviewed
Aug 22, 2024
@bagder Regarding the alternative patch (targeting |
Sure! |
vszakats
added a commit
to vszakats/curl
that referenced
this pull request
Aug 22, 2024
vszakats
added a commit
to vszakats/curl
that referenced
this pull request
Aug 22, 2024
vszakats
added a commit
to vszakats/curl
that referenced
this pull request
Aug 26, 2024
vszakats
added a commit
to vszakats/curl
that referenced
this pull request
Aug 27, 2024
vszakats
added a commit
to vszakats/curl
that referenced
this pull request
Aug 28, 2024
vszakats
added a commit
to vszakats/curl
that referenced
this pull request
Sep 1, 2024
1 task
vszakats
added a commit
that referenced
this pull request
Sep 2, 2024
Change mingw-w64 printf format checks in public curl headers to use `__MINGW_PRINTF_FORMAT` instead of `gnu_printf`. This syncs the format checker with format string macros published via `curl/system.h`. (Also disable format checks for mingw-w64 older than 3.0.0 (2013-09-20) and classic-mingw, which do not support this macro.) This fixes bogus format checker `-Wformat` warnings in 3rd party code using curl format strings with the curl printf functions, when using mingw-w64 7.0.0 (2019-11-10) and older (with GCC, MSVCRT). It also allows to delete two workaounds for this within curl itself: - setting `-D__USE_MINGW_ANSI_STDIO=1` for mingw-w64 via cmake and configure for `docs/examples` and `tests/http/clients`. Ref: c730c85 #14640 The format check macro is incompatible (depending on mingw-w64 version and configuration) with the C99 `%z` (`size_t`) format string used internally by curl. To work around this problem, override the format check style in curl public headers to use `gnu_printf`. This is compatible with `%z` in all mingw-w64 versions and allows keeping the C99 format strings internally. Also: - lib/ws.c: add missing space to an error message. - docs/examples/ftpgetinfo.c: fix to use standard printf. Ref: #14643 (take 1) Follow-up to 3829759 #12489 Closes #14703
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add tweak for mingw-w64 when building tests/http/client programs to
avoid a bogus
-Wformat
warning when using mingw-w64 v7.0.0 or older.The warning is bogus because these programs use curl's
printf()
implementation that is guaranteed to support that format spec.
Add this for both CMake and autotools. (But only CMake is CI tested with
an old toolchain.)
Apply the workaround to
docs/examples
, and fix an example to usecurl's
printf()
withCURL_FORMAT_CURL_OFF_T
.Reintroduce curl
printf()
calls intotests/http/client
, via #14625.Also restore large number masks to a printf, changed earlier in #14382.
Follow-up to 232302f #14382
Ref: #14625 (comment)
curl/system.h
instead?