thiscall calling convention

mike vertex at
Tue Oct 24 05:33:26 PDT 2006


Maybe you could try to google for "iasiothiscallresolver.h".

I used this in a C++ project (before I converted to D and trashed the  
code) to do all the ASIO stuff. I had used MinGW and couldn't link to the  
ASIO interface either (does only work from Visual C++), using this header  
file it worked. Maybe you can rewrite it and use it, don't know if it  
works in D, though.


Am 24.10.2006, 11:32 Uhr, schrieb Max Samuha <maxter at>:

> On Mon, 23 Oct 2006 09:59:56 -0400, "Jarrett Billingsley"
> <kb3ctd2 at> wrote:
>> "Max Samuha" <maxter at> wrote in message
>> news:o14pj2teu31k82a6rnqfc7jbk422lrm05l at
>>> I have a COM object which uses __thiscall linkage for its methods
>>> (guys who created the object have perfect sense of humor). Would you
>>> advice me of a good way to call those methods from D?
>> To use any COM interface from D, you can just create an interface which
>> derives from IUnknown.  D will make the interface COM-compatible.
>> import;
>> interface SomeInterface : IUnknown
>> {
>>    HRESULT method1();
>> }
>> extern(Windows) export CreateSomeInterface();
>> ...
>> SomeInterface i = CreateSomeInterface();
>> i.method1();
>> Of course, if the library you're using (what are you using anyway?)   
>> doesn't
>> have a function which creates an instance of the COM object for you,  
>> you'll
>> have to use QueryInterface from a base COM object, but..
> Thank you for the reply. It's not that i can't obtain the COM
> interface. I just can't call methods on that interface because the COM
> object implementation uses thiscall (not stdcall or cdecl) calling
> convention. This is an ASIO driver. The interface declaration does not
> specify the calling convention explicitly in their SDK (in C++):
> interface IASIO : public IUnknown
> {
> 	virtual ASIOBool init(void *sysHandle) = 0;
> 	virtual void getDriverName(char *name) = 0;	
> 	virtual long getDriverVersion() = 0;
> 	...
> }
> So MSVC++ which is used de facto to compile ASIO drivers for windows
> defaults to thiscall, effectively making the drivers crash when they
> are called by clients compiled in languages that don't support
> thiscall.
> I think, Walter has intended to add extern(C++): "C++ is reserved for
> future use". Will it be added?
> A wrapper could be used to fix that
> ( but someone may have a better
> idea?

Erstellt mit Operas revolutionärem E-Mail-Modul:

More information about the Digitalmars-d-learn mailing list