C++Builder: using variant type variable to store Delphi interface

| category: Programming | author: st
Tags: ,

Delphi case

Delphi supports interfaces natively. Any variable of variant type can store an interface like any allowed data types.

program IntfDelphi;

{$R *.res}

  Classes, SysUtils, Variants;

  ITest = interface(IInterface)
    procedure Foo(const Msg: string);

  TestImpl = class(TInterfacedObject, ITest)
    procedure Foo(const Msg …

Using Delphi library with C++ Builder

| category: Programming | author: st
Tags: ,

Since early XE versions C++ Builder supports Delphi units directly added in C++ project and compiles them as well as C/C++ source. However, this approach has several drawbacks:

  • Usually, Delphi files are stored in separated folders of other applications and packages. So your C++ project will point to many …