1

I inherited some Delphi components/code that currently compiles with C++ Builder 2007. I'm simply now trying to compile the components with C++ Builder RAD XE. I don't know Delphi (object pascal).

Here are the versions of the 'Supports' functions that appear to be in conflict. Is there a compiler switch I can use to make RAD XE backward compatible? Or is there something I can do to these function calls to correct the ambiguous nature?

The error I'm getting is:

[DCC Error] cxClasses.pas(566): E2251 Ambiguous overloaded call to 'Supports'
  SysUtils.pas(19662): Related method: function Supports(const TObject; const TGUID; out): Boolean;
  cxClasses.pas(467): Related method: function Supports(TObject; const TGUID; out): Boolean;



{$IFNDEF DELPHI5}

procedure FreeAndNil(var Obj);
var
  Temp: TObject;
begin
  Temp := TObject(Obj);
  Pointer(Obj) := nil;
  Temp.Free;
end;

function Supports(const Instance: IUnknown; const Intf: TGUID; out Inst): Boolean; overload;
begin
  Result := (Instance <> nil) and (Instance.QueryInterface(Intf, Inst) = 0);
end;


function Supports(Instance: TObject; const Intf: TGUID; out Inst): Boolean; overload;
var
  Unk: IUnknown;
begin
  Result := (Instance <> nil) and Instance.GetInterface(IUnknown, Unk) and
    Supports(Unk, Intf, Inst);
end;

{$ENDIF}


{$IFNDEF DELPHI6}

function Supports(const Instance: TObject; const IID: TGUID): Boolean;
var
  Temp: IUnknown;
begin
  Result := Supports(Instance, IID, Temp);
end;

{$ENDIF}
Eric
  • 1,697
  • 5
  • 29
  • 39
  • The easiest way to proceed may be to go to Delphi 2007 rather than Delphi XE. Your purchase of Delphi XE entitles you to use the older Delphi versions too, see http://www.embarcadero.com/products/delphi/previous-versions – LachlanG Feb 21 '11 at 06:27
  • @lachlan he's coding in C++ but using components whose sources are written in delphi. – David Heffernan Feb 21 '11 at 07:05

1 Answers1

5

You are using some devexpress components and the problem is that you are using versions of the code that pre-date C++ Builder XE. The particular problem is that the conditional defines declared in cxVer.inc do not know about XE. Consequently, this cxClasses.pas file does not know which version of Delphi it is targeting.

In most circumstances you could simply add the necessary defines and the code would start working. However, your version of the devexpress code is for RAD Studio 2007 which uses ANSI strings, but you are trying to compile on XE which uses Unicode strings. This difference needs major changes to the rest of the source code.

Unfortunately, to get this code to work on XE you will need to get hold of the latest versions of all your 3rd party components. The updated versions have had the necessary changes to support Unicode text.

What's more, your code may also need some significant re-work to support Unicode but I am less sure on that point because my experience is with Delphi rather than C++ Builder.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
  • That's correct, David. The components in question are DevExpress. I've stumbled through the conversion of another component adding Unicode. Changing AnsiChar to PByte or Byte if memory serves me. I looked at the cxver.inc and see that the code looks for a VER180 define, added that and get a new error E2003 undeclared identifier. I'm hoping to get lucky by being able to patch the code in the areas that need unicode support. – Eric Feb 20 '11 at 23:59
  • well good luck! if it's one of the smaller components you may be lucky. We weren't! – David Heffernan Feb 21 '11 at 00:01