[PATCH] widl: Handle C++ aggregate returns in a MSVC compatible way.

Jacek Caban jacek at codeweavers.com
Thu Jul 20 08:00:52 CDT 2017


Hi Henri,

On 20.07.2017 14:18, Henri Verbeet wrote:
> This mainly affects 64-bit winelib applications, and potentially mingw-w64
> usage of the Wine headers. As explained in commit
> fabfa59aea5c5b3201142382038beb3e76cb7567, MSVC returns aggregates through an
> implicit parameter immediately after the this/interface pointer. GCC's
> "ms_abi" attribute is supposed to match this, but unfortunately current
> versions of g++ (confirmed up to at least g++ 6.3) place the implicit return
> pointer before the this/interface pointer. See also
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52792.

FWIW, here is a bug about 32-bit problem:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64384

> This commit takes an approach similar to the earlier commit
> fabfa59aea5c5b3201142382038beb3e76cb7567: For ABI compatibility the return
> pointer is listed as an explicit parameter in the vtbl entry, while an inline
> helper is provided for source code compatibility.

While it fixes the problem for C++ callers, it breaks building classes
implementing those interfaces. Implementation will try to override
inline function instead of virtual one. Given that the workaround has
bad side effects, I'd say that we should at least try harder to not use
it. For example it could be #ifdefed to not be used by compilers doing
the right thing. With that, using our headers would require
modifications in compiled code compatible with MSVC, so there would be a
point in having a nice to use macro that interface implementations could
use to decide if they should apply needed changes. Obviously fixing
compilers sounds much better.

Jacek



More information about the wine-devel mailing list