[fpc-pascal] Implementing an interface force me to add _AddRef, _Release

Michael Van Canneyt michael at freepascal.org
Thu Apr 15 11:09:37 CEST 2010



On Thu, 15 Apr 2010, Zaher Dirkey wrote:

> IMyIntf = interface
>  function GetValue: Variant;
> end;
>
> TMyObject=(TList, IMyIntf)
>  ....
> end;
>
> Can not compile becuase it need to add this functions to TMyObject
>
>         function QueryInterface(const iid : tguid;out obj) : longint;stdcall;
>         function _AddRef : longint;stdcall;
>         function _Release : longint;stdcall;
>
> While i am not inherit IMyIntf from IUnknown or IInterface, Is there a
> way to not add unnecessary functions (for me at least).

All interfaces inherit from IUnknown, unless you use corba interfaces:
{$INTERFACES CORBA}

Michael.



More information about the fpc-pascal mailing list