Is there a tool which creates C header files for Delphi (Win32) DLLs?

风格不统一 提交于 2019-12-23 15:37:54

问题


Until now I have seen only tools and some information for the creation of Delphi code for a given C header file.

However, in the 'Delphi first' case, there is a Delphi interface declaration and a generated DLL, and no C header. Are there tools which can extract the necessary information and build a C header file for a DLL?

Such a tool could be helpful and time saving in cross-language / cross-platform projects. For example, with the C header file, it would be easier to create Java JNA binding code automatically with jnaerator. The tool chain would look like this:

Delphi source -> create C header -> convert to Java binding -> use Delphi DLL from Java


回答1:


Delphi's own compiler can output C/C++ header files from .pas files, using the -JPHNE parameter.




回答2:


While this works in theory, many Delphi DLLs will use calling conventions like register, don't pack records in standard C ways etc. Then on top there are RTL issues, coprocessor status word issues etc.

Probably most C compilers can workaround that by adding some pragma's, but I doubt the whole Java binding stuff will eat that.

So unless the DLL is crafted with this in mind, this will probably work more often not than that it will.

Reading and parsing the Delphi header is not that hard though. Pascal is easier to parse and transform than e.g. C. FPC (Free Pascal) has a pascal parser package that is used for its documentation tool that might be retargetable



来源:https://stackoverflow.com/questions/1205636/is-there-a-tool-which-creates-c-header-files-for-delphi-win32-dlls

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!