title: How to reference an external function from inside a unit
body: <p>I have two files. The first, <code>a.pas</code>, contains:</p>
  
  <pre><code>uses b;
  
  function f(x: integer): integer;
  begin
      f := x+1;
  end;
  
  begin
      writeln(g(10));
  end.
  </code></pre>
  
  <p>The file <code>b.pas</code> contains:</p>
  
  <pre><code>unit b;
  
  interface
  function g(x: integer): integer;
  
  implementation
  function g(x: integer): integer;
  begin
      g := f(x)*2;
  end;
  
  end.
  </code></pre>
  
  <p>Is it possible to somehow reference the function <code>f</code> defined in <code>a.pas</code>? I thought about using the <code>forward</code> keyword like this: (<code>b.pas</code>)</p>
  
  <pre><code>unit b;
  
  interface
  function g(x: integer): integer;
  
  implementation
  function f(x: integer): integer; forward;
  function g(x: integer): integer;
  begin
      g := f(x)*2;
  end;
  
  end.
  </code></pre>
  
  <p>But it doesn't work. It gives a "Forward declaration not solved" error.</p>
  
  <p>I also thought about using the <code>external</code> keyword but, in order to use the external <code>f</code> function, <code>b.pas</code> requires <code>a.pas</code> to be already compiled (but <code>a.pas</code> require <code>b.pas</code> as well).</p>
  
  <p>The only way to do this seems to be moving <code>f</code> (interface and implementation) to a new <code>helper.pas</code> file, and modifying <code>b.pas</code> like this:</p>
  
  <pre><code>unit b;
  
  interface
  function g(x: integer): integer;
  
  implementation
  uses helper;
  function g(x: integer): integer;
  begin
      g := f(x)*2;
  end;
  
  end.
  </code></pre>
  
  <p>I would prefer not having a <code>helper.pas</code> file. But maybe it's just impossible?</p>