directx bindings problem
Benjamin Thaut
code at benjamin-thaut.de
Tue Oct 29 13:33:46 PDT 2013
Am 29.10.2013 21:26, schrieb Heinz:
> On Tuesday, 29 October 2013 at 19:40:40 UTC, Benjamin Thaut wrote:
>> So I found it. Its actually your fault.
>>
>> IXAudio2Voice isn't a COM interface. That means it should _not_
>> inherit from IUnkown. But if it isn't a COM interface it can't be a
>> regular D interface either, because if it is a regular D-Interface it
>> will not have a v-table layout that conforms with C++. That means you
>> have to put "extern(C++)" in front of IXAudio2Voice to make it work.
>>
>> So to make stuff work you should change
>>
>> interface IXAudio2Voice : IUnknown
>>
>> to
>>
>> extern(C++) interface IXAudio2Voice
>>
>> Then everything works fine.
>>
>> Tip for the future: Using the "Microsoft Symbol Server" and the Visual
>> Studio Debugger you can easily verify if your COM interfaces call the
>> correct methods or if you messed up the declarations.
>>
>> Kind Regards
>> Benjamin Thaut
>
> Whoa! This did the trick with XAudio2! Thank you very much. I'll have
> the C++ linkage in mind for the rest of the DirectX APIs. One question:
> Should the other interfaces like IXAudio2 for example use extern(C++)
> whether they are COM interfaces or not?
>
> I'll also take your tip. I got the link for the symbol server. Do you
> have a link for a tutorial or something for the Visual Studio Debugger?
> I'd like more info about it. I assume the debug information from DMD is
> compatible with this debugger, right?
>
> Thank you again for your help and time.
The debug information are only compatible for 64-bit. But for 64-bit you
will run into other problems when debugging with the visual studio
debugger which require patching dmd to make it work.
For 32-bit they are in a different format but can be converted using
cv2pdb which is part of VisualD. You should really be using VisualD when
doing anything on windows. So the best option is using 32-bit and
converting the debug information (manually or using VisualD which does
it automatically) if you don't want to patch the compiler. If you need
64-bit and patching the compiler is an option I might be able to put up
a small how-to.
COM interfaces don't need to be declared as extern(C++). Only interfaces
that do not inherit from IUnkown and are actually C++ interfaces need to
be declared extern(C++)
Kind Regards
Benjamin Thaut
More information about the Digitalmars-d-learn
mailing list