[fpc-devel] corba interface casting

Sven Barth pascaldragon at googlemail.com
Mon Oct 1 17:40:50 CEST 2012


Am 01.10.2012 15:38, schrieb Paul Ishenin:
> Hello, FPC developers' list
>
> I have a code with 2 parent-child corba interfaces and 2 parent-child
> classes:
>
> Intf1 = interface
>    ...
> end;
>
> Intf2 = interface(Intf1)
>    ...
>    procedure DoSomething;
> end;
>
> Class1 = class
>    Intf: Intf1;
>    function GetIntf: Intf1; virtual;
> end;
>
> Class2 = class
>    Intf: Intf2;
>    function GetIntf: Intf1; override;
> end;
>
> function Class2.GetIntf: Intf1;
> begin
>    Result := Itnf; // this is Intf2
> end;
>
> var
>    C: Class2;
>    I: Intf2;
> ...
>    I := Intf2(C.GetIntf);
>
> Is this ^^^^ a correct interface cast? If not then how to cast one corba
> interface to another propely?
>
> I'm asking because without -CR the code compiles and with it gives an
> error Error: Class or COM interface type expected, but got "Intf2"

Did you try with "C.GetIntf as Intf2"? That should be the correct way to 
do this...

Regards,
Sven




More information about the fpc-devel mailing list