1

Inside a DPR I have

procedure A;
begin
  ...
  B;
  ...
end;

procedure B;
begin
  ...
  A;
  ...
end;

How to handle such case inside a DPR? inside a normal unit it's quite easy I just need to declare both procedures in the interface section of the unit, but inside a dpr how to do as their is no interface section.

zeus
  • 12,173
  • 9
  • 63
  • 184
  • That looks ripe for a stack overflow. – Freddie Bell Nov 04 '22 at 15:05
  • 1
    Other Qs about this: [Using procedure before it's defined](https://stackoverflow.com/a/20776557/4299358) and [Call a procedure from another function](https://stackoverflow.com/a/41551355/4299358) and [Call one procedure in another, that was declared before it](https://stackoverflow.com/a/61289609/4299358). @FreddieBell The dots/ellipsis could also stand for conditions. – AmigoJack Nov 04 '22 at 19:38

1 Answers1

10

You need to use a forward declaration:

procedure B; forward;

procedure A;
begin
  if 1 + 1 = 3 then
    B;
end;

procedure B;
begin
  if 1 + 1 = 3 then
    A;
end;

(Of course, forward declarations can also be used in the implementation section of units, so you don't need to pollute the unit's interface just to make two implementation-section routines know of each other.)

Andreas Rejbrand
  • 105,602
  • 8
  • 282
  • 384