[fpc-pascal] Passing a CORBA interface as parameter

Adriaan van Os fpc at microbizz.nl
Fri Dec 20 16:17:57 CET 2019


I would like to pass a CORBA interface-type as parameter and test for equality, So, for example, I have

{$mode objfpc}
{$interfaces corba}

type
	IMyInterface = Interface
	
		[  '{34aad6d0-5884-4143-97c2-b6e330305ae3}']

		Function MyFunc : Integer;
	end;

Now I can pass IMyInterface to TObject.GetInterface as the first parameter, which is of type TGuid 
in the declaration.

However, if I use the same TGuid parameter type in my own procedure

	procedure TestInterfaceParameter
	      ( const theInterface            : TGuid);
	    begin
	      if IsEqualGUID
	       ( theInterface, ITestInterface1)
	        then writeln
	           ( 'theInterface = ITestInterface1')
	    end;

then I run into the problem that IMyInterface is accepted as actual parameter of 
TestInterfaceParameter and of IsEqualGUID only if IMyInterface inherits from IUnknown (which I 
certainly don't want, as it is reference counted). Strangely, TObject.GetInterface does accept 
IMyInterface as a parameter. So where is the difference ? Is there some compiler magic involved in 
TObject.GetInterface ?

Regards,

Adriaan van Os






More information about the fpc-pascal mailing list