如何编写可移植 C/C++/Objective-C++针对 Apple iPhone/Mac OSX 的代码?
我正在处理一些在 Win32 和 VxWorks 上运行的 C/C++ 代码。它使用#ifdef WIN32 切换到特定于平台的实现。
我一直在 iPhone 上使用该代码,我想更新它并使其尽可能便携,但我不确定最佳实践是什么。到目前为止,我一直在使用 #ifdef __APPLE__
块。
我应该使用什么来定位 Apple iPhone 和 Mac OS X?
-
#ifdef __APPLE__
是最好的方法吗? - 有什么需要注意的问题吗?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以查看 __IPHONE_OS_VERSION_MIN_REQUIRED 来为不同版本的 iOS 划分代码。您还可以查看分区 基于 CPU,例如 32 位和 64 位 Intel 应用程序之间。
You might look at
__IPHONE_OS_VERSION_MIN_REQUIRED
to partition code for different versions of iOS. You might also look at partitioning based on CPU, e.g. between 32- and 64-bit Intel apps.