Forum > FPC development

Problem with Interface decleration


Hi together,
I have a problem with the D3D10 and I think this is a compiler issue.

The ID3D10EffectTechnique interface can not be used with fpc, but the same code works perfect in delphi.
Thats the decleration (from the JSB translation):

--- Code: ---ID3D10EffectTechnique = class // Cannot use 'interface' as the QueryInterface, AddRef and Release methods are missing.
        function IsValid: LongBool; virtual; stdcall; abstract;

        function GetDesc(out Desc: TD3D10_TechniqueDesc (* out *)
        ): HResult; virtual; stdcall; abstract;

        function GetAnnotationByIndex(Index: LongWord): ID3D10EffectVariable; virtual; stdcall; abstract;

        function GetAnnotationByName(Name: PAnsiChar): ID3D10EffectVariable; virtual; stdcall; abstract;

        function GetPassByIndex(Index: LongWord): ID3D10EffectPass; virtual; stdcall; abstract;

        function GetPassByName(Name: PAnsiChar): ID3D10EffectPass; virtual; stdcall; abstract;

        function ComputeStateBlockMask(out StateBlockMask: TD3D10_StateBlockMask (* __out *)
        ): HResult; virtual; stdcall; abstract;

--- End code ---

I have not tried to do the translation myself, but also not success. this is the original MS Header definition:

--- Code: ---DECLARE_INTERFACE(ID3D10EffectTechnique)
    STDMETHOD_(ID3D10EffectVariable*, GetAnnotationByIndex)(THIS_ UINT Index) PURE;
    STDMETHOD_(ID3D10EffectVariable*, GetAnnotationByName)(THIS_ LPCSTR Name) PURE;
    STDMETHOD_(ID3D10EffectPass*, GetPassByIndex)(THIS_ UINT Index) PURE;
    STDMETHOD_(ID3D10EffectPass*, GetPassByName)(THIS_ LPCSTR Name) PURE;
    STDMETHOD(ComputeStateBlockMask)(THIS_ _Out_ D3D10_STATE_BLOCK_MASK *pStateBlockMask) PURE;
--- End code ---
This is a C definitions, so the QueryInterface, AddRef and Release functions are missing, for that JSB is right.

The workaround with the class does work for Delphi, but seems not to work for FPC. when i debug through a example source-code it seems not code is called (but no exception is thrown).

When I define like this

--- Code: ---ID3D10EffectTechnique = interface
--- End code ---
then i got a SIGSEGV exception calling any methods of the interface, I think that the VMT is not right, cause the IUnknown functions are not existing.

but the debugger says its inherited from IUnknown.

as far as it seems, the sentence in the MSDN "All interfaces derives from IUnknown" is not correct  :o

How to solve this problem, any workaround possible ?

best regards

Hi there,

with fpc 2.7 and the CORBA interface it's working :)


[0] Message Index

Go to full version