Converting DLL wrapper units from Delphi to Lazarus lazarus / 31-LCL ---------------------------------------------------------------------- Curt Carpenter · 2011-09-01 03:18 I have a library of Delphi wrappers for some DLLs that I use, and I am converting them for use in Lazarus.  In the interface of the Lazarus wrapper unit, I declare a function -- for example function sdDisplaySampling    (Ch1Enabled:               Bool;      Ch2Enabled:               Bool;     TriggerSource:            Word;    Timebase:                    Word;     BufferSize:                  Word;    var Time:                    Double): DOUBLE     stdcall;  The code for this function is included in the DLL "SDKDLL.DLL", so in the implementation section of the wrapper I write: function sdDisplaySampling:   external 'SDKDLL.DLL'; This generates a compiler error.  On the other hand, if I recreate the entire function declaration in the implementation section, and add the external clause, as in:  function sdDisplaySampling    (Ch1Enabled:               Bool;      Ch2Enabled:               Bool;     TriggerSource:            Word;    Timebase:                    Word;     BufferSize:                  Word;    var Time:                    Double): DOUBLE     stdcall;   external 'SDKDLL.DLL' This compiles fine. Can anyone confirm that this last form, with the entire function definition re-created in both the interface and implementation sections, is going to work at run-time?   If that's right, I'd like to include a note to this effect in the "converting Delphi to Lazarus" wiki. ---------------------------------------------------------------------- Leledumbo · 2011-09-01 08:59 QuoteCan anyone confirm that this last form, with the entire function definition re-created in both the interface and implementation sections, is going to work at run-time?Actually, just in the interface section (assuming it would be called from other units) with repeated header. Remember that FPC implements function overloading so without repeating the header the compiler can't decide which function to call. If you want to omit it, use either mode TP or Delphi. ---------------------------------------------------------------------- Curt Carpenter · 2011-09-01 20:47 I don't mind including the full function declaration in both the interface and implementation sections -- it's just a copy/paste after all, and makes maintenance just a little bit easier too I think (no need to skip back and forth between sections to find the information you need). The function overload explanation makes perfect sense -- thanks.  I'm not used to the possibility of overloading at all. But I'm still not exactly sure what the minimum requirement is to declare an external function in both the interface and implementation sections of a unit.  This isn't a big deal, but knowing would let me write a better input for the Delphi-to-Lazarus wiki.  I'll play with the possibilities some more when I get the chance.  Thanks again. Thanks for the ---------------------------------------------------------------------- Leledumbo · 2011-09-01 21:13 QuoteBut I'm still not exactly sure what the minimum requirement is to declare an external function in both the interface and implementation sections of a unit.As I said, just once with full parameters and external modifier in either section, depending who would call it. But usually a wrapper is of course meant to be used by other units so interface section should be the correct place.