Bug 3732 – Not all COM interfaces inherit from IUnknown.

Status
RESOLVED
Resolution
INVALID
Severity
minor
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2010-01-20T19:59:00Z
Last change time
2015-06-09T01:28:19Z
Assigned to
nobody
Creator
burton-radons

Comments

Comment #0 by burton-radons — 2010-01-20T19:59:05Z
Well this is rude. It turns out some COM interfaces - I specifically know of ID3D10Include (http://msdn.microsoft.com/en-us/library/ee419311%28VS.85%29.aspx) - do not inherit from IUnknown. Since inheritance from IUnknown is how DMD applies its magic, it means that such interfaces cannot be implemented directly from D. It would seem preferable to have a "pragma (COM)" or "pragma (com)" attribute to apply to an interface to cause it and its descendants to be understood to be COM participants than to inherit from IUnknown, which seems an outdated commonality, unfortunately. The justification from Microsoft's side seems to be that ID3D10Include objects should be lightweight, so removing IUnknown allows them to be stack objects since it's impossible for anyone to retain a living reference to them after returning.
Comment #1 by bugzilla — 2010-01-21T15:42:45Z
Does the interface not have aquire, release, and queryinterface methods?
Comment #2 by burton-radons — 2010-01-22T08:25:15Z
Nope. I've since found that this is also common to most of the interfaces used in the reflection API for DirectX 10 and 11, which you're not supposed to implement. I think the intent is the same, just the opposite direction - they're trying to serve objects whose lifetimes are completely dependent on the root object.
Comment #3 by yebblies — 2011-06-12T22:52:43Z
The correct solution would be to use extern(C++) interfaces. The bug is really in microsoft calling something a com class which isn't.