C 函数指针转换为 Delphi/Pascal?
我目前正在将一些 C 标头翻译成 Delphi。我找不到将函数指针从 C 转换为 Delphi 的参考。
typedef _JAlloc JAlloc;
struct _JAlloc {
void *(*alloc) (JAlloc *allocator, size_t size);
void (*free) (JAlloc *allocator, void *p);
void *(*realloc) (JAlloc *allocator, void *p, size_t size);
};
这个的 Delphi 翻译是什么?
在哪里可以找到将 C 头文件手动转换为 Delphi 的好资源(包括指针、预处理器指令等)?
I am currently translating some C headers into Delphi. I am unable find a reference for converting a function pointer from C into Delphi.
typedef _JAlloc JAlloc;
struct _JAlloc {
void *(*alloc) (JAlloc *allocator, size_t size);
void (*free) (JAlloc *allocator, void *p);
void *(*realloc) (JAlloc *allocator, void *p, size_t size);
};
What will be the Delphi translation of this?
Where can I find good resources for manual conversion of C headers to Delphi (including pointer, preprocessor directives, etc.)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用这种代码
并将 cdecl 更改为 stdcall,具体取决于您的 C 库的调用约定。
另一种声明(也许更“帕斯卡式”)可能是:
Use this kind of code
And change cdecl to stdcall, depending of the calling convention of your C library.
An alternative declaration (more 'pascalish' perhaps) could be:
Bob 博士的 HeadConv 实用程序是一个很好的用于将 C 声明转换为 Delphi 的实用程序,也是一个很好的学习工具,用于将 C 源代码与等效的 Pascal 源代码进行比较。
您可以在这里找到它
Dr. Bob's HeadConv utility is a good one to use for converting C declarations into Delphi, and is a good learning tool for comparing C source code to the equivalent Pascal source code.
You can find it here