[PATCH 1/5] avicap32: Define NONAMELESSUNION in files that include objidl.h.

Alexandre Julliard julliard at winehq.org
Tue Dec 17 14:47:47 CST 2019


Zebediah Figura <z.figura12 at gmail.com> writes:

> On 12/17/19 12:42 PM, Alexandre Julliard wrote:
>> Zebediah Figura <zfigura at codeweavers.com> writes:
>> 
>>> On 12/17/19 11:37 AM, Alexandre Julliard wrote:
>>>> Zebediah Figura <z.figura12 at gmail.com> writes:
>>>>
>>>>> Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47710
>>>>> Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
>>>>> ---
>>>>> This is not currently necessary, but will be with the prescribed solution for
>>>>> bug 47710, viz. defining the type _STGMEDIUM_UNION.
>>>>
>>>> I'm not sure I understand what fix you are proposing, but if it requires
>>>> Winelib users to also define NONAMELESSUNION I don't think it's a viable
>>>> solution.
>>>>
>>>
>>> Essentially, this:
>>>
>>> ---
>>> diff --git a/include/objidl.idl b/include/objidl.idl
>>> index a0ad1f6e01f..4c56c422747 100644
>>> --- a/include/objidl.idl
>>> +++ b/include/objidl.idl
>>> @@ -1427,7 +1427,7 @@ interface IAdviseSink : IUnknown
>>>    } GDI_OBJECT;
>>>
>>>    typedef struct _userSTGMEDIUM {
>>> -    union switch(DWORD tymed) u {
>>> +    union _STGMEDIUM_UNION switch(DWORD tymed) u {
>>>      case TYMED_NULL:     ;
>>>      case TYMED_MFPICT:   wireHMETAFILEPICT hMetaFilePict;
>>>      case TYMED_ENHMF:    wireHENHMETAFILE hHEnhMetaFile;
>>> ---
>>>
>>> Which causes warnings anywhere that nameless unions are used:
>>>
>>> ---
>>> In file included from ../../../wine/include/objbase.h:258,
>>>                  from ../../../wine/include/ole2.h:25,
>>>                  from ../../include/strmif.h:13,
>>>                  from ../../../wine/dlls/wmcodecdspuuid/wmcodecdspuuid.c:22:
>>> ../../include/objidl.h:6109:21: warning: declaration does not declare
>>> anything
>>>  6109 |     } DUMMYUNIONNAME;
>> 
>> I'm afraid we'll have to find a different fix then.
>> 
>
> I understand the difficulty, but I'm not sure what else we can
> reasonably do here. As far as I can see either we have to throw C++
> under the bus (i.e. close that bug as WONTFIX), or we have to add
> specific differences into widl (or objidl.idl) for winelib, to avoid
> violating the C spec. That either means making the structure type
> anonymous (i.e. not defining _STGMEDIUM_UNION), which is not
> particularly great (not that it's particularly likely anyone would want
> to use the _STGMEDIUM_UNION type), or forcibly giving the union member a
> name (which would also potentially require changes in winelib user code).
>
> But maybe I'm missing another, more perfect option.

If the issue is C++ code, this can be fixed by providing a different
definition with judicious use of cpp_quote and #ifdef __cplusplus.

If the issue is C code accessing the structure members, it would be OK
to require that code to be modified. But we can't require modifying
every file that happens to include the header without any interest in
that specific structure.

-- 
Alexandre Julliard
julliard at winehq.org



More information about the wine-devel mailing list