[cfe-dev] COM ABI support?

Stephen Lin swlin at post.harvard.edu
Wed Jul 10 19:10:19 PDT 2013


> Did you try COM with Clang?
> I doubt COM requires special ABI support from the compiler.
> A COM interface is just a group of abstract virtual function,
> same as how we use the concept "interface" in C++.
> There is no special thing in COM, IMHO.

Wang,

Correct me if I'm wrong, but, as I understand it (my last usage of COM
was maybe 10 years ago...), COM interfaces are a language-independent
ABI that happen to be implementable using C++ virtual inheritance
using MSVC. In other words, any language can access COM objects by
creating data structures that map to the interface exposed by COM
(which allows dynamic dispatch through tables of function pointers and
standardized interface querying and memory management interface);
however, in order for COM objects to also be C++ objects (i.e. for the
dynamic dispatch in COM to map to virtual dispatch in C++), it
requires that, among other things, the C++ ABI used by the compiler
creates virtual tables that are laid out in the same manner that COM
objects lay out their interface tables. Since Microsoft is the author
of the COM ABI and also MSVC, they obviously saw to it that the
latter's ABI is compatible with the former; however, full MSVC C++ ABI
compatibility is not required to be compatible with the COM subset.

The reason why I am asking is because it seems like the difficult part
of supporting the MSVC C++ ABI is reverse engineering various details
that Microsoft does not have documented anywhere, like name mangling
schemes and various rules for things like constructor/destructor
creation and linkages. However, it seems like a lot of this is not
really required for the COM subset; for the most part, just making
virtual table structures and calling conventions conform to the COM
ABI would be enough for COM support, so I'm wondering if that's
already there or not. I could not find any prior discussion about this
topic in particular.

Thanks,
Stephen



More information about the cfe-dev mailing list