Why does the compiler say that the implementation is “different from the previous declaration” when they look the same?

I have two units, the first one is my interface:

use personas

interface

type
  Tllave = array[0..31] of byte;
  Tdatos = array of byte;

  ImyInterface = interface(IInterface)

    function nombre : string;
    function edad : integer;
    procedure resetear;
    function Proceso(datos : tdatos; cantidad : integer) : integer ;    
    procedure Iniciar(llave : Tllave);
  end;

second unit, my object declaration:

use militares

interface

uses personas;

type

  Tmilitares = Class(TInterfacedObject, ImyInterface )
    public
      function nombre : string;
      function edad : integer;
      procedure resetear;
      function Proceso(datos : Tdatos; cantidad : integer) : integer ;    
      procedure Iniciar(llave : Tllave);
    published
      constructor create;
  end;

implementation

function tmilitares.Proceso(datos : tdatos; cantidad : integer) : integer ; // getting error !!
begin
  // ....
end;


procedure tmilitares.Iniciar(llave : Tllave); // getting error!!
begin
  // ....
end;

I get an error only in the "proceso" and "iniciar" functions:

The 'Iniciar' ad is different from the previous ad.
The "Proceso" ad is different from the previous ad.

I noticed that they have an array parameter. The type of the parameter is determined in the first block, if I define these types in the second units, I get the same error, but this manifests itself in the declaration of the object. how can i compile?

+5
3

, , , , (Tdatos Tllave) Tmilitares . , use, militares.

, .


:

, , .

, , . . , . , ! uses.

+10

. , . , iMyInterface.SomeProcedure(unit1 ) , , , (unit2 ). , , ImyInterface, .

Unit1:

unit Unit1;


interface

type   
  Tllave = array[0..31] of byte;  

  Tdatos = array of byte;

  ImyInterface = interface(IInterface)

    function nombre : string;
    function edad : integer;
    procedure resetear;
    function Proceso(datos : tdatos; cantidad : integer) : integer ;
    procedure Iniciar(llave : Tllave);   end;

implementation


  //stuff.

end.

Unit2:

unit Unit2;

interface

{$M+}

uses Unit1;

type

  Tmilitares = Class(TInterfacedObject, ImyInterface )
    public
      function nombre : string;
      function edad : integer;
      procedure resetear;
      function Proceso(datos : Tdatos; cantidad : integer) : integer ;    
      procedure Iniciar(llave : Tllave);
    published
      constructor create;
  end;

implementation


function Tmilitares.nombre: string;
begin

end;

function tmilitares.Proceso(datos : tdatos; cantidad : integer) : integer ; // no more error 
begin
  // ....
end;


constructor Tmilitares.create;
begin

end;

function Tmilitares.edad: integer;
begin

end;

procedure Tmilitares.resetear;
begin

end;

procedure tmilitares.Iniciar(llave : Tllave); // no more error.
begin
  // ....
end;

end.
0

, , , :

unit Unit1;

interface
  uses Generics.Collections;

type
  TFoo = class
  end;

  TFooList = class(TObjectList<TFoo>)
    protected
      procedure Notify(const Item: TFoo; Action: TCollectionNotification); override;
  end;

implementation

uses Classes;

procedure TFooList.Notify(const Item: TFoo; Action: TCollectionNotification);
var
 sl : TStringList;
begin
  //
end;

end.

[ dcc32] Unit1.pas(20): E2037 ""
[dcc32 Error] Unit1.pas(12): E2065 : 'TFooList.Notify' [dcc32 Fatal Error] Project1.dpr(6): F2063 'Unit1.pas'

, ,

System.Classes :: TCollectionNotification = (cnAdded, cnExtracting, cnDeleting);

a:

System.Generics.Collections :: TCollectionNotification = (cnAdded, cnRemoved, cnExtracted);

- . Ctrl + CLICK , . , uses .

It is bad when the null error of duplicating type names in our own code is doubly bad when Emba does this in its RTL.

0
source

All Articles