[PATCH v2 0/1] MR18: 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. -- v2: include: Use __MINGW_PRINTF_FORMAT when compiling with MinGW. https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/18
From: Zebediah Figura <zfigura(a)codeweavers.com> 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. --- include/private/vkd3d_common.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/private/vkd3d_common.h b/include/private/vkd3d_common.h index 9a2de265..78a15c19 100644 --- a/include/private/vkd3d_common.h +++ b/include/private/vkd3d_common.h @@ -54,7 +54,11 @@ static inline size_t align(size_t addr, size_t alignment) #ifdef __GNUC__ # define VKD3D_NORETURN __attribute__((noreturn)) -# define VKD3D_PRINTF_FUNC(fmt, args) __attribute__((format(printf, fmt, args))) +# ifdef __MINGW_PRINTF_FORMAT +# 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 # define VKD3D_UNUSED __attribute__((unused)) # define VKD3D_UNREACHABLE __builtin_unreachable() #else -- GitLab https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/18
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" ``` -- https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/18#note_10382
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: ```c ... #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. -- https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/18#note_10952
This merge request was approved by Henri Verbeet. -- https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/18
participants (4)
-
Henri Verbeet (@hverbeet) -
Zebediah Figura -
Zebediah Figura -
Zebediah Figura (@zfigura)