include: Use __MINGW_PRINTF_FORMAT when compiling with MinGW.
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
Activity
+# 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.
added 13 commits
-
4af58cbe...73cf9dee - 12 commits from branch
wine:master
- ba8ea289 - include: Use __MINGW_PRINTF_FORMAT when compiling with MinGW.
-
4af58cbe...73cf9dee - 12 commits from branch
Unfortunately, this doesn't appear to play very nice with the
-D__USE_MINGW_ANSI_STDIO=0
we pass formake 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.
added 11 commits
-
ba8ea289...6b45f290 - 10 commits from branch
wine:master
- 303ce66c - include: Use __MINGW_PRINTF_FORMAT when compiling with MinGW.
-
ba8ea289...6b45f290 - 10 commits from branch