X1008 Integer and HRESULT interchanged (Delphi)

From RAD Studio
Jump to: navigation, search

Go Up to Error and Warning Messages (Delphi) Index


In Delphi, Integer, Longint, and HRESULT are compatible types, but in C++ the types are not compatible and will produce differently mangled C++ parameter names. To ensure that there are no problems linking object files created with the Delphi compiler, this message alerts you to possible problems. If you are compiling your source to an object file, this is an error. Otherwise, it is a warning.

The following example declares the interface and class methods differently. While they are equivalent in Delphi, they are not so in C++.

program Produce;
  uses Windows;

  type
    I0 = interface (IUnknown)
      procedure p0(var x : Integer);
    end;

    C0 = class (TInterfacedObject, I0)
      procedure p0(var x : HRESULT);
    end;

  procedure C0.p0(var x : HRESULT);
  begin
  end;

begin
end.

The easiest solution to this problem is to match the class-declared methods to be identical to the interface-declared methods.

program Solve;

  uses Windows;

  type
    I0 = interface (IUnknown)
      procedure p0(var x : Integer);
    end;

    C0 = class (TInterfacedObject, I0)
      procedure p0(var x : Integer);
    end;

  procedure C0.p0(var x : Integer);
  begin
  end;

begin
end.