mirror of
https://github.com/curl/curl.git
synced 2026-07-23 01:07:16 +03:00
printf: fix mingw-w64 format checks
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:c730c8549b#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 to3829759bd0#12489 Closes #14703
This commit is contained in:
parent
6004f96734
commit
e512fbfa67
12 changed files with 22 additions and 33 deletions
|
|
@ -34,10 +34,6 @@ foreach(_target IN LISTS check_PROGRAMS)
|
|||
if(LIB_SELECTED STREQUAL LIB_STATIC AND WIN32)
|
||||
set_property(TARGET ${_target_name} APPEND PROPERTY COMPILE_DEFINITIONS "CURL_STATICLIB")
|
||||
endif()
|
||||
if(MINGW)
|
||||
# For mingw-w64 7.0.0 and earlier to avoid '-Wformat='
|
||||
set_property(TARGET ${_target_name} APPEND PROPERTY COMPILE_DEFINITIONS "__USE_MINGW_ANSI_STDIO=1")
|
||||
endif()
|
||||
set_target_properties(${_target_name} PROPERTIES
|
||||
OUTPUT_NAME "${_target}" UNITY_BUILD OFF
|
||||
PROJECT_LABEL "Example ${_target}")
|
||||
|
|
|
|||
|
|
@ -46,11 +46,6 @@ if USE_CPPFLAG_CURL_STATICLIB
|
|||
AM_CPPFLAGS += -DCURL_STATICLIB
|
||||
endif
|
||||
|
||||
if HAVE_MINGW
|
||||
# For mingw-w64 7.0.0 and earlier to avoid '-Wformat='
|
||||
AM_CPPFLAGS += -D__USE_MINGW_ANSI_STDIO=1
|
||||
endif
|
||||
|
||||
# Prevent LIBS from being used for all link targets
|
||||
LIBS = $(BLANK_AT_MAKETIME)
|
||||
|
||||
|
|
|
|||
|
|
@ -75,8 +75,8 @@ int main(void)
|
|||
res = curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD_T,
|
||||
&filesize);
|
||||
if((CURLE_OK == res) && (filesize>0))
|
||||
curl_mprintf("filesize %s: %" CURL_FORMAT_CURL_OFF_T " bytes\n",
|
||||
filename, filesize);
|
||||
printf("filesize %s: %" CURL_FORMAT_CURL_OFF_T " bytes\n",
|
||||
filename, filesize);
|
||||
}
|
||||
else {
|
||||
/* we failed */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue