Silence inttypes.h compiler warnings on Windows #3237

pull Diapolo wants to merge 1 commits into bitcoin:master from Diapolo:silence changing 1 files +10 −0
  1. Diapolo commented at 9:53 PM on November 11, 2013: none
    • the warnings are related to MinGWs inttypes.h (observed with MinGW based on GCC version 4.8.1 (rev5, Built by MinGW-W64 project) and likely other version also suffer from this)
    • fixes #3236
  2. Silence inttypes.h compiler warnings on Windows
    - the warnings are related to MinGWs inttypes.h (observed with MinGW based
      on GCC version 4.8.1 (rev5, Built by MinGW-W64 project) and likely
      other version also suffer from this)
    - fixes #3236
    387f2c5e7a
  3. BitcoinPullTester commented at 10:26 PM on November 11, 2013: none

    Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/387f2c5e7a14f7d8773dda0d72d85f5563c7347d for binaries and test log. This test script verifies pulls every time they are updated. It, however, dies sometimes and fails to test properly. If you are waiting on a test, please check timestamps to verify that the test.log is moving at http://jenkins.bluematt.me/pull-tester/current/ Contact BlueMatt on freenode if something looks broken.

  4. wtogami commented at 3:30 AM on November 12, 2013: contributor

    Please verify that it continues to build and work as expected with the Precise 12.04-based win32 gitian which has mingw based on gcc-4.6.x.

  5. laanwj commented at 7:42 AM on November 12, 2013: member

    @diapolo If I understand this correctly you're giving yourself too little credit. This does not only silence warnings, but it fixes printf format strings throughout the source code for Windows builds.

    ACK in any case

  6. laanwj commented at 8:38 AM on November 12, 2013: member

    Maybe we should add some sprintf tests to catch problems with this in the pulltester.

  7. laanwj commented at 11:55 AM on November 12, 2013: member

    @diapolo Can you try removing the inttypes.h include completely on WIN32? I think it's only used for PRId64 (and friends) at this point and we shouldn't use C99 headers on WIN32.

  8. Diapolo commented at 5:02 PM on November 12, 2013: none

    I'll check this out tomorrow... thanks for helping out.

  9. brandondahler commented at 4:55 AM on November 13, 2013: contributor

    @Diapolo this only coincidentally fixes most instances of the warning because util.h is depended on by almost every file (indirectly at least). The inttypes.h include is spread across all of the files that use PRI[xdu]64 directly.

    I would rather spend some time getting rid of all of the *printf functions and replace them with [i,o][,f,string]streams where appropriate. Once that is done, there will be no dependence on inttypes.h anywhere.

  10. laanwj commented at 7:26 AM on November 13, 2013: member

    It is quite urgent to fix this because it breaks strprintf on Windows XP and earlier (see http://sourceforge.net/apps/trac/mingw-w64/wiki/gnu%20printf) @brandondahler have you checked how much strprintf is used? There's at least 130 direct usages. Converting that all to iostreams would be a massive endavour. Had I realized that inttypes.h was C99 I would not have ACKed your refactor :/ `

    So unless we revert all those changes it forces us into the C99 route for the short term even on Windows. Thus to define __USE_MINGW_ANSI_STDIO and use the mingw C99 equivalent functions. I'd rather not have because this burns all the bridges to MSVC support, but no one cared about that anyway so it's not much of a loss.

    In the longer term boost::format is a typesafe printf-backward-compatible function that natively uses std::strings, so I think that would be the way to go to replace strprintf. The syntax is different though (http://www.boost.org/doc/libs/1_55_0/libs/format/doc/format.html) so this still implies quite a lot of work.

  11. laanwj commented at 10:38 AM on November 13, 2013: member

    Continued in #3244

  12. laanwj closed this on Nov 13, 2013

  13. Diapolo deleted the branch on Nov 13, 2013
  14. Bushstar referenced this in commit 0c9c27c6fd on Apr 8, 2020
  15. DrahtBot locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-13 18:16 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me