gpt4 book ai didi

c - typedef 解决 dll 包装器问题

转载 作者:行者123 更新时间:2023-11-30 18:08:33 25 4
gpt4 key购买 nike

我想为 DLL 文件编写一个包装,在本例中是为 python 编写的。问题是参数类型不是 C 标准类型。它们已被类型定义为其他内容。

我有 DLL 文件的头文件...因此我可以手动跟踪参数类型所定义的原始标准 C 类型。但想要一种更系统的方法来做到这一点。我想知道是否有一个实用程序可以评估头文件,或者您是否可以在 dll 中的某个位置获取类型定义。

最佳答案

我认为您正在寻找的工具是 SWIG :

SWIG is a software development tool that connects programs written in C and C++ with a variety of high-level programming languages. SWIG is used with different types of languages including common scripting languages such as Perl, PHP, Python, Tcl and Ruby. The list of supported languages also includes non-scripting languages such as C#, Common Lisp (CLISP, Allegro CL, CFFI, UFFI), Java, Lua, Modula-3, OCAML, Octave and R. Also several interpreted and compiled Scheme implementations (Guile, MzScheme, Chicken) are supported. SWIG is most commonly used to create high-level interpreted or compiled programming environments, user interfaces, and as a tool for testing and prototyping C/C++ software. SWIG can also export its parse tree in the form of XML and Lisp s-expressions. SWIG may be freely used, distributed, and modified for commercial and non-commercial use.

这确实假设您愿意使用 DLL 的 header 。如果您想单独使用 DLL,那么您还有更多工作要做。它可能提供一个可用于分析类型的反射接口(interface)。如果做不到这一点,您就会陷入痛苦的世界 - 或者对 DLL 中的任何调试信息进行逆向工程。

关于c - typedef 解决 dll 包装器问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3251501/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com