Open raedrizqie opened 1 month ago
The colliding definitions are:
#ifdef __cplusplus
#define __FIReference_1_BYTE ABI::Windows::Foundation::IReference<BYTE >
#endif /* __cplusplus */
and
#ifdef __cplusplus
#define __FIReference_1_boolean ABI::Windows::Foundation::IReference<boolean >
#endif /* __cplusplus */
because boolean
and BYTE
are both typedefed to unsigned char
.
This breakage was introduced by the change in windows.foundation.idl
in https://github.com/mingw-w64/mingw-w64/commit/77eaa959e2a66abdf0893d4d6b187036a9d7ed52 which added interface Windows.Foundation.IReference<boolean>
I have asked about this issue in the relevant upstream merge request https://gitlab.winehq.org/wine/wine/-/merge_requests/6594
I don't think this is a bug in Wine. Native headers have both Windows.Foundation.IReference<BYTE>
and Windows.Foundation.IReference<boolean>
and no conflicts.
windows.foundation.h
in wInsdk does not have the string IReference
at all from what I can see.
It's in windows.foundation.idl
it seems slightly different here, no?
struct __declspec(uuid("3c00fd60-2950-5939-a21a-2d12c5a01b8a"))
IReference<bool> : IReference_impl<ABI::Windows::Foundation::Internal::AggregateType<bool, boolean>> {
static const wchar_t* z_get_rc_name_impl() {
return L"Windows.Foundation.IReference`1<Boolean>"; }
};
typedef IReference<bool> __FIReference_1_boolean_t;
#define ____FIReference_1_boolean_FWD_DEFINED__
#define __FIReference_1_boolean ABI::Windows::Foundation::__FIReference_1_boolean_t
In both the latest winsdk 10.0.22621.0 and the 4-year-old winsdk 10.0.19041.0, windows.foundation.h
does not contain IReference
. 10.0.14393.0 is ancient at this point.
Frankly I don't quite understand how the different instantiations of IReference
are being handled in the winsdk. It seems in the winsdk they are spread across different headers, practically being defined "on demand" only if a header file requires a specific instantiation (an example being windows.ui.xaml.controls.primitives.h
).
However it is possible that we can ignore this difference here. Practically speaking, it doesn't matter as long as the generated definitions are actually correct...
...But it looks like the definition of IReference<boolean>
is wrong. Instead of becoming
struct IReference<boolean > : IReference_impl<boolean >
it should become
struct IReference<bool> : IReference_impl<ABI::Windows::Foundation::Internal::AggregateType<bool, boolean>>
WinRT has a native boolean type which, according to https://learn.microsoft.com/en-us/windows/win32/winrt/base-data-types is supposed to be mapped to bool
in C++. In fact, anything that uses boolean
in the IDL probably needs special handling in WIDL.
I would argue interface Windows.Foundation.IReference<boolean>
should be removed from the IDL until WIDL can handle it properly.
[19:37:14]
WIDL generates GUID e5198cc8-2873-55f5-b0a1-84ff9e4aad62
forIReference<BYTE>
, which matchesIReference<byte>
in windows.device.usb.h from Windows SDK. [19:38:17]WIDL also generates GUID 3c00fd60-2950-5939-a21a-2d12c5a01b8a
forIReference<boolean>
, which matchesIReference<bool>
in windows.media.import.h from Windows SDK. [19:39:34]the second one is incorrect. the GUID 3c00fd60-2950-5939-a21a-2d12c5a01b8a
belongs toIReference<Boolean>
. [19:40:17]IReference<boolean>
shall be the same asIReference<BYTE>
; it's a redeclaration and no class should be generated.
Congrats! This issue breaks both Firefox and Chromium.
I think that you can try patching WIDL. The quick, dirty and improper fix would be to tamper with the tokenizer so it treats boolean
as BYTE
.
nodejs
is also affected by this bug
Would it be a proper workaround to remove the IReference<boolean>
in the IDL file? I can create a PR to remove that.
I have added a pull request to workaround the issue. The workaround will fail if IReference<boolean>
is used in any other winrt IDL files.
Description / Steps to reproduce the issue
Got redefinition error when compiling qt6-webengine:
Expected behavior
Compiles without error.
Actual behavior
Compile error.
Verification
Windows Version
MINGW64_NT-10.0-19045
MINGW environments affected
Are you willing to submit a PR?
No response