For my application I need to create a DLL from Delphi (to be more precise Delphi compatible code written within Lazarus IDE compiled by free pascal under linux) using stdcall.
When using that DLL (for example in Matlab or so) one needs of course the meta information for passing the arguments - often realised with a header file.
I'm searching for a tool do to that running on the delphi source code. Something like h2pas
-reverse.
My research yielded no results. As I think, there is no such tool, I'd like to find a table or other information, how the Delphi/Pascal data types are mapped to C types and how to work with records.
Howto create C-Header for Delphi/Free Pascal/Lazarus DLL - data types
2.2k views Asked by Bastian Ebeling At
1
I have used the below construct to generate header files compatible with the C-mode compiler of Visual C++ 6 from Delphi 5 code when Delphi had the -JPH switch (see notes below).
Note that I have not used this since Delphi 5, but the switch has since then been expanded:
Somewhere along the line, the JPHNE switch has been added to the
dcc32
command-line compiler:Rudy Velthuis has a nice article using the JPHNE switch.
It certainly does not handle all types, and you will need quite a bit of HPPEMIT and EXTERNALSYM directives.
I uploaded my Delphi 5 to Visual C++ 6 HPP conversion from back then to BitBucket.
It generates the .hpp files to import the DLL that was written in Delphi.
Notes from the Delphi 5 era: