Skip to content
Snippets Groups Projects

include: Use __MINGW_PRINTF_FORMAT when compiling with MinGW.

Merged Elizabeth Figura requested to merge zfigura/vkd3d:pr1 into master

The default for MinGW is always ms_printf rather than gnu_printf, but if we are using ucrtbase or ANSI stdio, we want gnu_printf.

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
    • +# if defined(__MINGW32__)
      +#  define VKD3D_PRINTF_FUNC(fmt, args) __attribute__((format(__MINGW_PRINTF_FORMAT, fmt, args)))
      +# else
      +#  define VKD3D_PRINTF_FUNC(fmt, args) __attribute__((format(printf, fmt, args)))
      +# endif

      Should we just check whether __MINGW_PRINTF_FORMAT is defined instead of __MINGW32__?

    • Zebediah Figura replied on the mailing list:

      On 9/27/22 05:28, Henri Verbeet (@hverbeet) wrote:
      >> \`\`\`diff
      >> +# if defined(__MINGW32__)
      >> +#  define VKD3D_PRINTF_FUNC(fmt, args) __attribute__((format(__MINGW_PRINTF_FORMAT, fmt, args)))
      >> +# else
      >> +#  define VKD3D_PRINTF_FUNC(fmt, args) __attribute__((format(printf, fmt, args)))
      >> +# endif
      >> \`\`\`
      > Should we just check whether \_\_MINGW_PRINTF_FORMAT is defined instead of \_\_MINGW32\_\_?
      > 
      
      I don't think it makes a difference, but sure, that works too.
    • Please register or sign in to reply
  • Elizabeth Figura added 13 commits

    added 13 commits

    Compare with previous version

    • Unfortunately, this doesn't appear to play very nice with the -D__USE_MINGW_ANSI_STDIO=0 we pass for make crosstest. For example:

        CCLD     tests/d3d12.cross32.exe
      In file included from <vkd3d>/tests/d3d12_crosstest.h:46,
                       from <vkd3d>/tests/d3d12.c:24:
      <vkd3d>/tests/d3d12.c: In function ‘check_heap_desc_’:
      <vkd3d>/tests/d3d12.c:124:13: warning: format ‘%u’ expects argument of type ‘unsigned int’, but argument 4 has type ‘UINT64’ {aka ‘const long long unsigned int’} [-Wformat=]
                   "Got size %"PRIu64", expected %"PRIu64".\n",
                   ^~~~~~~~~~~~
                   desc->SizeInBytes, expected.SizeInBytes);
                   ~~~~~~~~~~~~~~~~~
      <vkd3d>/include/private/vkd3d_test.h:68:35: note: in definition of macro ‘VKD3D_TEST_OK’
               vkd3d_test_ok(vkd3d_line, __VA_ARGS__); } while (0)
                                         ^~~~~~~~~~~
      <vkd3d>/tests/d3d12.c:123:5: note: in expansion of macro ‘ok_’
           ok_(line)(desc->SizeInBytes == expected.SizeInBytes,
           ^~~
      In file included from <vkd3d>/include/private/vkd3d_test.h:24,
                       from <vkd3d>/tests/d3d12_crosstest.h:46,
                       from <vkd3d>/tests/d3d12.c:24:
      /usr/share/mingw-w64/include/inttypes.h:94:20: note: format string is defined here
       #define PRIu64 "I64u"
    • Zebediah Figura replied on the mailing list:

      On 10/12/22 07:43, Henri Verbeet (@hverbeet) wrote:
      > Unfortunately, this doesn't appear to play very nice with the `-D__USE_MINGW_ANSI_STDIO=0` we pass for `make crosstest`. For example:
      > 
      > \`\`\`
      >    CCLD     tests/d3d12.cross32.exe
      > In file included from <vkd3d>/tests/d3d12_crosstest.h:46,
      >                   from <vkd3d>/tests/d3d12.c:24:
      > <vkd3d>/tests/d3d12.c: In function ‘check_heap_desc_’:
      > <vkd3d>/tests/d3d12.c:124:13: warning: format ‘%u’ expects argument of type ‘unsigned int’, but argument 4 has type ‘UINT64’ {aka ‘const long long unsigned int’} [-Wformat=]
      >               "Got size %"PRIu64", expected %"PRIu64".\n",
      >               ^~~~~~~~~~~~
      >               desc->SizeInBytes, expected.SizeInBytes);
      >               ~~~~~~~~~~~~~~~~~
      > <vkd3d>/include/private/vkd3d_test.h:68:35: note: in definition of macro ‘VKD3D_TEST_OK’
      >           vkd3d_test_ok(vkd3d_line, __VA_ARGS__); } while (0)
      >                                     ^~~~~~~~~~~
      > <vkd3d>/tests/d3d12.c:123:5: note: in expansion of macro ‘ok_’
      >       ok_(line)(desc->SizeInBytes == expected.SizeInBytes,
      >       ^~~
      > In file included from <vkd3d>/include/private/vkd3d_test.h:24,
      >                   from <vkd3d>/tests/d3d12_crosstest.h:46,
      >                   from <vkd3d>/tests/d3d12.c:24:
      > /usr/share/mingw-w64/include/inttypes.h:94:20: note: format string is defined here
      >   #define PRIu64 "I64u"
      > \`\`\`
      > 
      
      I don't see that here, but judging by the failure mode it looks like a 
      gcc bug. Perhaps it's a problem with an older gcc version?
      
      If so, I think we can work around it by reverting a06d54d24e, though. 
      (Cf. the discussion on that patch, at [1].)
      
      [1] https://www.winehq.org/pipermail/wine-devel/2022-January/205258.html
    • I don't see that here, but judging by the failure mode it looks like a gcc bug. Perhaps it's a problem with an older gcc version?

      It's more straightforward than that, actually. My mingw stdio.h contains the following code:

      ...
      #elif defined(__USE_MINGW_ANSI_STDIO)
      #define __MINGW_PRINTF_FORMAT gnu_printf
      #define __MINGW_SCANF_FORMAT  gnu_scanf
      #else
      ...

      which clearly isn't going to work very well with -D__USE_MINGW_ANSI_STDIO=0. That particular box is due for an upgrade though, and this works fine with the version of mingw in Debian stable, so this patch is fine.

    • Please register or sign in to reply
  • Henri Verbeet approved this merge request

    approved this merge request

  • added 11 commits

    Compare with previous version

  • Alexandre Julliard approved this merge request

    approved this merge request

Please register or sign in to reply
Loading