[gmpi] Re: low level API - Abstract Factory summary

  • From: "B.J. Buchalter" <bj@xxxxxxxxxx>
  • To: "gmpi@xxxxxxxxxxxxx" <gmpi@xxxxxxxxxxxxx>
  • Date: Mon, 07 Feb 2005 22:38:12 -0500

on 2/7/05 9:13 PM, Tim Hockin at thockin@xxxxxxxxxx wrote:

> On Mon, Feb 07, 2005 at 08:53:56PM -0500, Paul Davis wrote:
>> this is not the same situation as you describe for COM. but i just
>> have a bad feeling about the assumption that you can write a single
>> interface and assume that it works for C and C++
>> "natively". obviously, any C interface (more or less) can be in C++
>> but only in the "C-like" way. This is part of the reason that a number
>> of us insisted on C as the implementation language for the spec.
> 
> I too feel dirty about this.  I'm trusting the C++ experts on this, but
> it feels very delicate to me...

Relying on the compiler to build a COM compatible vtable is risky. I believe
that the current version of gcc does at this point. The current version of
CodeWarrior for Mac kinda does. But doing this relies on using features of
compilers that are *completely* implementation defined (just like vtable
layouts, non-POD objects, etc. etc. are implementation defined in C++). It
is a convenient approach to writing code, but in our investigation of doing
this, it does not seem like you can (by definition) rely on the C++ code you
write actually compiling to valid COM implementations without assuming
specific compilers, and this is certainly true if you don't restrict to
windows. OTOH, it may be the case that, since COM is making its way across
the platforms, all C++ compilers will conform to the COM vtable
specifications (e.g. first member of object is pointer to vtable, virtual
members are placed in vtable in order that they appear in class
declaration). That being said it still seems really fragile to me; one
difference in the C++ compiler's implementation of vtable layouts, all the
code breaks.

AFAIK, the requirement that all COM methods return HRESULT (long) greatly
simplifies the kind of macros that one might write to implement the vtables
in straight C (since you know that all methods return something, and all
methods take at least one argument.

Best regards,


B.J. Buchalter

Metric Halo
5 Donovan Drive
Hopewell Junction, NY 12533 USA
tel +1 845 223-6112
fax +1 603 250-2451


----------------------------------------------------------------------
Generalized Music Plugin Interface (GMPI) public discussion list
Participation in this list is contingent upon your abiding by the
following rules:  Please stay on topic.  You are responsible for your own
words.  Please respect your fellow subscribers.  Please do not
redistribute anyone else's words without their permission.

Archive: //www.freelists.org/archives/gmpi
Email gmpi-request@xxxxxxxxxxxxx w/ subject "unsubscribe" to unsubscribe

Other related posts: