Justin808
Justin808

Reputation: 21512

Is there a pre-compiler define that tells me I'm compiling for iOS?

Is there a pre-compiler define that tells me I'm compiling for iOS?

Something like __APPLE__ that lets me know I'm compiling on a mac.

Upvotes: 2

Views: 444

Answers (1)

Cody Gray
Cody Gray

Reputation: 244732

Sure; in GCC:

#ifdef __APPLE__
  #include "TargetConditionals.h"

  #ifdef TARGET_OS_IPHONE
    // targeting the iPhone
  #elif TARGET_IPHONE_SIMULATOR
    // targeting the iOS simulator
  #elif TARGET_OS_MAC
    // targeting the Mac OS
  #else
    // unknown target platform
  #endif
#else
  // non-Apple platform
#endif

Upvotes: 3

Related Questions