Home > Back-end >  set parameter of record inside record and viceversa - Delphi
set parameter of record inside record and viceversa - Delphi

Time:12-21

I would like to know how to declare a record parameter which is another record, and declare the same record inside of the other record.

Example :

  record1 = record
    param1 : Byte;
    param2 : Byte;
    param3 : ^record2;
  end;

  record2 = record
    param1 : Byte;
    param2: Byte;
    param3 : record1;
  end;

When I do this, the compiler says identifier redeclared, I don't know why.

CodePudding user response:

I fixed my issue making pointer upside the 2 records.

PRecord1 = ^record1;
PRecord2 = ^record2;

record1 = record
  param1 : Byte;
  param2 : Byte;
  param3 : PRecord2;
end;

record2 = record
  param1 : Byte;
  param2: Byte;
  param3 : PRecord1;
end;
  • Related