简体   繁体   English

在 Mac OS X 上结合 Objective-C 和 C/C++

[英]Combining Objective-C and C/C++ on Mac OS X

Can I create an Objective-C library (by XCode) and use it in my C/C++ application (compiled by GCC without supporting Objective-C).我可以创建一个 Objective-C 库(通过 XCode)并在我的 C/C++ 应用程序中使用它(由 GCC 编译,不支持 Objective-C)。

You can try this tool (it's fairly raw at the moment) to generate C/C++ bindings for Objective-C code (created to help get Wine [C only] code working with OSX[Objective-C] libraries).您可以尝试使用此工具(目前还很原始)为 Objective-C 代码生成 C/C++ 绑定(创建它是为了帮助使 Wine [C only] 代码与 OSX [Objective-C] 库一起使用)。

This email explains how the tool came about and has the binding generating code as an attachment.此 email 解释了该工具是如何产生的,并将绑定生成代码作为附件。

http://www.winehq.org/pipermail/wine-devel/2011-April/089657.html The download is actually a tar.gz. http://www.winehq.org/pipermail/wine-devel/2011-April/089657.html下载的其实是一个tar.gz。

You could give it a shot yourself and then try emailing Charles about using it if it's too much trouble (and bug him to set it up as a proper project somewhere. :-)您可以自己试一试,然后尝试通过电子邮件向查尔斯发送有关使用它的问题,如果太麻烦的话(并让他在某处将其设置为适当的项目。:-)

You need to create a C or C++ interface for your Objective-C code, so you can use this interface to call the Objective-C code from your C/C++ code. You need to create a C or C++ interface for your Objective-C code, so you can use this interface to call the Objective-C code from your C/C++ code. Note that you can take advantage of Cocoa's toll-free bridging: eg you can return an NSString* and interpret it as a CFStringRef in your C/C++ code.请注意,您可以利用 Cocoa 的免费桥接:例如,您可以返回 NSString* 并将其解释为 C/C++ 代码中的 CFStringRef。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM