Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@mback2k
Copy link
Member

@mback2k mback2k commented Aug 29, 2020

This removes the following compiler warnings:

tool_filetime.c: In function 'setfiletime':
tool_filetime.c:106:15: warning: ISO C does not support the 'I' printf flag [-Wformat=]
  106 |               "Failed to set filetime %" CURL_FORMAT_CURL_OFF_T
      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~
tool_filetime.c:106:15: warning: format '%d' expects argument of type 'int', but argument 3 has type 'curl_off_t' {aka 'long long int'} [-Wformat=]
In file included from ../include/curl/curl.h:38,
                 from ../lib/curl_setup.h:157,
                 from tool_setup.h:36,
                 from tool_filetime.h:24,
                 from tool_filetime.c:22:
../include/curl/system.h:199:42: note: format string is defined here
  199 | #  define CURL_FORMAT_CURL_OFF_T     "I64d"
tool_filetime.c:125:17: warning: ISO C does not support the 'I' printf flag [-Wformat=]
  125 |                 "Failed to set filetime %" CURL_FORMAT_CURL_OFF_T
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~
tool_filetime.c:125:17: warning: format '%d' expects argument of type 'int', but argument 3 has type 'curl_off_t' {aka 'long long int'} [-Wformat=]
In file included from ../include/curl/curl.h:38,
                 from ../lib/curl_setup.h:157,
                 from tool_setup.h:36,
                 from tool_filetime.h:24,
                 from tool_filetime.c:22:
../include/curl/system.h:199:42: note: format string is defined here
  199 | #  define CURL_FORMAT_CURL_OFF_T     "I64d"
tool_filetime.c:133:15: warning: ISO C does not support the 'I' printf flag [-Wformat=]
  133 |               "Failed to set filetime %" CURL_FORMAT_CURL_OFF_T
      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~
tool_filetime.c:133:15: warning: format '%d' expects argument of type 'int', but argument 3 has type 'curl_off_t' {aka 'long long int'} [-Wformat=]
In file included from ../include/curl/curl.h:38,
                 from ../lib/curl_setup.h:157,
                 from tool_setup.h:36,
                 from tool_filetime.h:24,
                 from tool_filetime.c:22:
../include/curl/system.h:199:42: note: format string is defined here
  199 | #  define CURL_FORMAT_CURL_OFF_T     "I64d"

@mback2k mback2k added the Windows Windows-specific label Aug 29, 2020
@mback2k mback2k requested review from MarcelRaad and jay August 29, 2020 12:38
@mback2k mback2k self-assigned this Aug 29, 2020
@bagder
Copy link
Member

bagder commented Aug 29, 2020

I find this curious. These have been like this for a very long time in the curl headers. Were they always wrong or did something change?

@mback2k
Copy link
Member Author

mback2k commented Aug 29, 2020

I have seen them since initially creating my buildbots years ago. I just never spend the time to figure out where this came from before. I am also not sure if this fix works for old MinGW versions.

@mback2k mback2k marked this pull request as draft August 29, 2020 20:01
@mback2k
Copy link
Member Author

mback2k commented Aug 29, 2020

Seems like my local environment and the Windows CI are out of sync. I guess this warning showing up in my local builds, but this PR breaking the Windows CI is related to different GCC versions. Back to draft, have to investigate this first.

@jay
Copy link
Member

jay commented Aug 29, 2020

warning: ISO C does not support the 'I' printf flag

Looks like gcc. The Windows CRT supported %I64d before %lld. In early versions %lld the extra l was ignored.

@MarcelRaad
Copy link
Member

I think I've had this since my MinGW-w64 updated to GCC 10. But only in this one place. All other similar occurrences don't result in this warning - which is suppressed anyway with -Wno-pedantic-ms-format both with autotools and CMake. I don't understand that and didn't have the time to investigate yet.

@mback2k
Copy link
Member Author

mback2k commented Aug 30, 2020

Okay, so this is a new warning then. I still think I have seen similar warnings all the time with my old (no longer existing and migrated to Azure) Windows buildbot infrastructure. So it seems like changing the defines as proposed with this PR is not a good idea without checking the compiler version somehow, right? I will try to update the PR to reflect that.

Fixes warning: ISO C does not support the 'I' printf flag
which is raised starting with GCC 10 for tool_filetime.c.

Assisted-by: Jay Satiro
Assisted-by: Marcel Raad

Closes curl#5891
@jay
Copy link
Member

jay commented Aug 31, 2020

So it seems like changing the defines as proposed with this PR is not a good idea without checking the compiler version somehow, right?

It's not the compiler version that's the issue. If you build curl with mingw it will run using the default CRT which may not support %lld. I'd rather just silence the warning.

@MarcelRaad
Copy link
Member

I'd rather just silence the warning.

The problem is that the warning actually is disabled (with --wno-pedantic-ms-format), and it works in all other places, but stopped working in tool_filetime.c. Looks like a MinGW bug.

@mback2k
Copy link
Member Author

mback2k commented Sep 1, 2020

I'd rather just silence the warning.

The problem is that the warning actually is disabled (with --wno-pedantic-ms-format), and it works in all other places, but stopped working in tool_filetime.c. Looks like a MinGW bug.

The error only appears for lines 125 and 133 where another format specifier %u follows %CURL_FORMAT_CURL_OFF_T. So it seems like GCC slips over the first one and steps over the second one.

@mback2k
Copy link
Member Author

mback2k commented Sep 6, 2020

Does anybody else have an idea on how to fix this? I guess my approach was invalid and I have no other idea at the moment.

@jay
Copy link
Member

jay commented Sep 7, 2020

If Marcel is right and it is a gcc bug showing you a warning that you've disabled then it's not a curl problem.

@mback2k
Copy link
Member Author

mback2k commented Sep 11, 2020

Closing this as this approach led to nothing useful...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Windows Windows-specific

Development

Successfully merging this pull request may close these issues.

4 participants