Delphi Error – X1008 Integer and HRESULT interchanged

Delphi Compiler Error

X1008 Integer and HRESULT interchanged

Reason for the Error & Solution

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.

Share:

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

Delphi Compiler Error E2313 Attribute – Known attribute cannot specify properties Reason for the Error & Solution No further information...
Delphi Compiler Error E2379 Virtual methods not allowed in record types Reason for the Error & Solution No further information...
Rodrigo , one of the long time Delphi Developer has been working on one of his personal project “Delphi IDE...