title: Writing Delphi/FreePascal DLL to be called from gcc application
body: <p>I need to make parts of my Win32 Delphi app available to another company's Linux gcc program.</p>
  
  <p>Throughput and deployment requirements make any sort of remote service unsuitable so I'm looking at using FreePascal to build a .SO (Linux equivalent of a DLL) that the gcc app can call.</p>
  
  <p>It's a long time since I used C/C++ and never on Linux so I'm a little unsure as to how best to structure the DLL/SO interface for compatibility with a gcc caller.</p>
  
  <p>Here's a representation of my data structures</p>
  
  <pre><code>TFoo = record
    x, y : double;
    a : smallint;
    b : string;
  end;
  
  TBar = record
    a : double;
    b : longint;
    c : string;
  end;
  
  TFooBar = record
    foo : array of TFoo;
    bar : array of TBar;
  end;
  
  procedure Process(const inFooBar : TFooBar);
  </code></pre>
  
  <p>To make this Process method externally available via a FreePascal .SO how do I need to modify these declarations? I'm thinking something along the lines of</p>
  
  <pre><code>TFoo = record
    x, y : double;
    a : smallint;
    b : PChar;
  end;
  
  TBar = record
    a : double;
    b : longint;
    c : PChar;
  end;
  
  TFooBar = record
    foo : ^TFoo;
    foo_count : longint;
    bar : ^TBar;
    bar_count : longint;
  end;
  
  procedure Process(const inFooBar : TFooBar);
  </code></pre>
  
  <p>Am I on the right track? I don't have to get this exactly right, the other company's programmers will very likely fix up my mistakes. I just don't want them to laugh too hard when they see what I've sent them.</p>