views:

84

answers:

1

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 code 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?
+1  A: 

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.

Alex Reynolds