https://bugs.winehq.org/show_bug.cgi?id=53431
Bug ID: 53431 Summary: widl generates enum forward declarations in typedefs which are not valid in C++ Product: Wine Version: 7.13 Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: tools Assignee: wine-bugs@winehq.org Reporter: gfw.kra@gmail.com Distribution: ---
Hi everyone,
I recently discovered an issue with C++ code in headers compiled from winrt idl's using widl. It does not compile when included, when tried using mingw g++ v12.1.0. There’s seems to be issue with how enum typedefs are translated within namespaces.
Example:
When tried to include windows.media.speechsynthesis.h compiled from windows.media.speechsynthesis.idl in cpp file, the following output is received (compiler output shows headers from mingw, but these look the same when compiled using widl in wine).
``` /usr/x86_64-w64-mingw32/include/windows.foundation.h:90:26: error: use of enum ‘PropertyType’ without previous declaration 90 | typedef enum PropertyType PropertyType; | ^~~~~~~~~~~~ /usr/x86_64-w64-mingw32/include/windows.foundation.h:164:18: error: using typedef-name ‘ABI::Windows::Foundation::PropertyType’ after ‘enum’ 164 | enum PropertyType { | ^~~~~~~~~~~~ /usr/x86_64-w64-mingw32/include/windows.foundation.h:90:39: note: ‘ABI::Windows::Foundation::PropertyType’ has a previous declaration here 90 | typedef enum PropertyType PropertyType; | ^~~~~~~~~~~~ /usr/x86_64-w64-mingw32/include/windows.media.speechsynthesis.h:218:30: error: use of enum ‘VoiceGender’ without previous declaration 218 | typedef enum VoiceGender VoiceGender; | ^~~~~~~~~~~ /usr/x86_64-w64-mingw32/include/windows.media.speechsynthesis.h:476:22: error: using typedef-name ‘ABI::Windows::Media::SpeechSynthesis::VoiceGender’ after ‘enum’ 476 | enum VoiceGender { | ^~~~~~~~~~~ /usr/x86_64-w64-mingw32/include/windows.media.speechsynthesis.h:218:42: note: ‘ABI::Windows::Media::SpeechSynthesis::VoiceGender’ has a previous declaration here 218 | typedef enum VoiceGender VoiceGender; | ^~~~~~~~~~~ /usr/x86_64-w64-mingw32/include/windows.media.speechsynthesis.h:822:30: error: using typedef-name ‘ABI::Windows::Media::SpeechSynthesis::VoiceGender’ after ‘enum’ 822 | enum VoiceGender *value) = 0; | ^~~~~~~~~~~ /usr/x86_64-w64-mingw32/include/windows.media.speechsynthesis.h:218:42: note: ‘ABI::Windows::Media::SpeechSynthesis::VoiceGender’ has a previous declaration here 218 | typedef enum VoiceGender VoiceGender; ```
windows.media.speechsynthesis.idl has typedef of enum VoiceGender, which is defined later. ``` namespace Windows { namespace Foundation { interface IClosable; } namespace Media { namespace SpeechSynthesis { typedef enum VoiceGender VoiceGender; ```
This is translated to following: ``` #ifdef __cplusplus namespace ABI { namespace Windows { namespace Media { namespace SpeechSynthesis { typedef enum VoiceGender VoiceGender; } } } } #else /* __cplusplus */ typedef enum __x_ABI_CWindows_CMedia_CSpeechSynthesis_CVoiceGender __x_ABI_CWindows_CMedia_CSpeechSynthesis_CVoiceGender; #endif /* __cplusplus */ ```
This typedef is not valid in C++. According to the standard, enum cannot be forward declared using typedef. This could be replaced with just simple enum declaration, but it would need to have type specifier (that goes for definition as well).
Best regards.
https://bugs.winehq.org/show_bug.cgi?id=53431
Fabian Maurer dark.shadow4@web.de changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |dark.shadow4@web.de
--- Comment #1 from Fabian Maurer dark.shadow4@web.de --- Should be fixed as of wine 8.10, at least it seems working. Can you please retest?