https://issues.dlang.org/show_bug.cgi?id=16987
Issue ID: 16987
Summary: ABI error wrt. COM interfaces returning structs
Product: D
Version: D2
Hardware: All
OS: Windows
Status: NEW
Severity: major
Priority: P1
Component: dmd
Assignee: [email protected]
Reporter: [email protected]
>From http://forum.dlang.org/post/[email protected], relevant
wrt. interfacing with DirectX libraries:
COM classes/interfaces are apparently subject to a separate ABI. Unfortunately,
googling it hasn't turned up any official (and not even some inofficial)
documentation so far. Based on the first few tests on Win64, integers are
returned in RAX, floats (and I guess doubles too) in XMM0, and structs (incl.
2x int32 and 2x float) via hidden sret pointer, with `this` pointer in RCX (1st
arg) and `sret` in RDX (2nd arg). Compared to the normal Win64 C++ ABI it just
seems more conservative by always returning structs via hidden pointer.
While at it, please also fix https://issues.dlang.org/show_bug.cgi?id=16527 by
simply swapping the order of `this` and `sret` pointer arguments on Windows
(32-bit: extern(C++) methods only, 64-bit: always; LDC already does so).
--