4

I'm trying to create a shell extension to provide EXIF information for JPEG files in Windows Explorer "infotips", and am using Lazarus as this needs to produce an x64 DLL.

Does Lazarus support multiple inheritance with interfaces, and if so, how do I go about it?

for example, something like:

type
  IInfoTips = interface(IPersistFile, IQueryInfo)

Thanks, Mark

Mark K Cowan
  • 1,755
  • 1
  • 20
  • 28

2 Answers2

0

Both interfaces are defined in shlobj for Free Pascal/Lazarus, just like on Delphi. If symbols changed units during the Delphi lifetime, we try to put them in the more recent units, but there is a large backlog there.

All this should be largely Delphi compatible, maybe it is easier if you explained what exactly doesn't work like expected.

Added after Arnaud's comments:

No it does not. Objects implement interfaces in Pascal. I don't really understand why it is really important to do this anyway. Sure it is a bit of syntactic sugar, but since any delphi style interface implements Iunknown, you can just query an interface for another interface:

uses activex;

var x :IPersistfile;
    y :IPersistStream;
begin
  x.queryinterface(IID_IPersistStream,y);
end.
Marco van de Voort
  • 25,628
  • 5
  • 56
  • 89
  • IMHO you did not answer the question. The question was "do FPC support multiple inheritance in interfaces". Delphi "unmanaged" does not, even in latest versions. Only Delphi for .Net did. Does FPC? I guess neither... – Arnaud Bouchez Apr 15 '16 at 12:40
  • It is all too long ago, so I don't know why the answer and the question mismatch. Anyway I reviewed the question and answered it. – Marco van de Voort Apr 16 '16 at 17:46
  • I'm afraid you still do not answer the question. It was not about implementation of an interface, but about interface definition itself. Question was if an interface may have multi-inheritance, as it is possible in C# or Java AFAIR. Such multi-inheritance of interfaces could have their benefit. I came to this old question because I needed it, found out that Delphi did not allow it, and wanted to be sure that I did not miss anything, and that multi-inheritance was really not implemented by Delphi (but Delphi for .Net). This nice feature is still in the QC loop... And not implemented in FPC... – Arnaud Bouchez Apr 18 '16 at 13:17
  • And the first word of my second answer is NO. And the rest is why I don't see the benefit AND a workaround. – Marco van de Voort Apr 18 '16 at 17:42
0

No, interfaces in FPC does not support multi-inheritance yet.

What you can do is letting the implementation class inherit from both interfaces:

type
  TMyInfoTips = class(TInterfacedObject, IPersistFile, IQueryInfo)

But not at interface level, as you wish. Such statements won't compile:

type
  IInfoTips = interface(IPersistFile, IQueryInfo)

You can only "inherit" from a single interface type.

Delphi does not support it either. Only the defunct Delphi for .Net compiler did... but because .Net/C# IR supports (and expects) the feature.

I'm also missing this feature in Delphi or FPC.

Arnaud Bouchez
  • 42,305
  • 3
  • 71
  • 159