Thread overview
Using COM. Please help.
Jun 27, 2011
Nub Public
Jun 27, 2011
Andrej Mitrovic
Jun 27, 2011
Nub Public
Jun 27, 2011
David Nadlinger
Jun 27, 2011
Nub Public
June 27, 2011
Hi. I've been trying to use Direct2D and I ran into some problems.

1. When translating the headers from the Windows SDK, what linkage should I use for the interfaces? Currently I use none and it works, but I want some confirmation in case something comes up later and bites my in the @ss.

2. Some members in the Direct2D interfaces are inlined. This gives me access violations when I declare and use them in my files. I guess those members are not exported to the Direct2D dlls. But there's no inline keyword in D. How do I solve this?

Help please.
June 27, 2011
You mean COM interfaces? I usually do this:

interface SomeComInterface : IUnknown
{
    extern(Windows):
    BOOL PrototypeFoo();
}

But maybe this is already implicit when deriving from IUnknown, I wouldn't know.

But from what I can tell some of those prototypes seem to have C linkage, maybe you're getting access violations due to wrong calling conventions.
June 27, 2011
On 6/27/2011 1:28 PM, Andrej Mitrovic wrote:
> You mean COM interfaces? I usually do this:
>
> interface SomeComInterface : IUnknown
> {
>      extern(Windows):
>      BOOL PrototypeFoo();
> }
>
> But maybe this is already implicit when deriving from IUnknown, I wouldn't know.
>
> But from what I can tell some of those prototypes seem to have C
> linkage, maybe you're getting access violations due to wrong calling
> conventions.


Thanks for the reply. But it still doesn't work.

interface ISomeComInterface : IUnknown
{
	void funcWithManyParams(/*10 params*/);

	extern(/*insert whatever linkage here*/)
	void funcWrapperWithLessParams(/*3 params*/)
	{
		funcWithManyParams(/*fill in some default params*/);
	}
	//this func is inlined in the MS SDK header
}

DMD complains that the function body of funcWrapperWithLessParams isn't abstract.
June 27, 2011
On 6/27/11 9:04 AM, Nub Public wrote:
> DMD complains that the function body of funcWrapperWithLessParams isn't
> abstract.

I don't know if there is something COM-specific going on, but you might want to mark the wrapper method »final« – that's at least how it works for normal interfaces.

David
June 27, 2011
On 6/27/2011 4:08 PM, David Nadlinger wrote:
> On 6/27/11 9:04 AM, Nub Public wrote:
>> DMD complains that the function body of funcWrapperWithLessParams isn't
>> abstract.
>
> I don't know if there is something COM-specific going on, but you might
> want to mark the wrapper method »final« – that's at least how it works
> for normal interfaces.
>
> David


It works now. Thanks.