开发者

How to write Portable C/C++/Objective-C++ code to target Apple iPhone/Mac OSX?

开发者 https://www.devze.com 2023-01-09 13:59 出处:网络
I\'m working with some C/C++ code that runs on Win32 and also VxWorks. It uses #ifdef WIN32 to switch to platform specific implementations.

I'm working with some C/C++ code that runs on Win32 and also VxWorks. It uses #ifdef WIN32 to switch to platform specific implementations.

I've been using the c开发者_开发技巧ode on the iPhone and I want to update it and keep it as portable as possible, but I'm not sure what's the best practice. So far I've been using #ifdef __APPLE__ blocks.

What should I be using to target Apple iPhone and Mac OS X?

  • Is #ifdef __APPLE__ the best approach?
  • Are there any gotchas to be aware of?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消