如何在objective-c++中编译特定文件,在objective-c中编译项目的其余部分 [英] How to compile specific files in objective-c++ and the rest of the project in objective-c

查看:29
本文介绍了如何在objective-c++中编译特定文件,在objective-c中编译项目的其余部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正忙于一个项目,我需要使用外部附件来阅读 Mifare 1k标签.

I'm currently busy on a project where I need to use an external accessory to read Mifare 1k tags.

附件提供了一个 SDK,用 (Objective ?)C++ 编写,我按照提供的说明将 XCode 设置为将源代码编译为:Objective-C++"并在其他链接器标志"中添加了-Obj-C++".

The accessory was provided with an SDK, written in (Objective ?)C++ and I followed the instructions provided to set XCode to "Compile sources as: Objective-C++" and added "-Obj-C++" in "Other linkers flags.

SDK 编译得很好,但问题是我已经在项目中使用了几个库(例如 ASIHTTPRequest、JSONKit 等),并且由于这些库中的那些新设置,我遇到了编译问题.如果我切换回之前的设置,我会在阅读器的 SDK 中遇到编译问题

The SDK compiles fine then, but trouble is I am already using several libraries in the project (such as ASIHTTPRequest, JSONKit, ...) and I get compilation problems because of those new settings in those libraries. If I switch back to the previous settings, I get compilation problems in the reader's SDK

问题是:有没有办法只将 SDK 中的类编译为 C++,而将项目的其余部分编译为 Objective-c?

The question is: is there a way to compile only the class from the SDK as C++ and the rest of the project as objective-c ?

SDK 文件仅包含 .h(和一个链接库)

the SDK files consists only of .h (and a linked library)

感谢您的帮助,迈克

推荐答案

尝试将库头文件重命名为 myClass.h(用于接口)和 myClass.mm(用于实现文件).这会强制将文件编译为 Objective-C++.

Try renaming the files where you are including the library headers to myClass.h for interface and myClass.mm for implementation files. This forces the files to be compiled as objective-c++.

这篇关于如何在objective-c++中编译特定文件,在objective-c中编译项目的其余部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆