Search code examples
activexmultiple-inheritanceexplorerlazarus

Interfaces in Lazarus/FPC: Multiple inheritance


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


Solution

  • 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.