Search code examples
iosc-preprocessorcompiler-flags

What to use for iOS compiler define


I have the following code that I want to run on Iphone OS, what compiler flag should I use for IOS and where in the below code should it be inserted? Thanks

  #if defined(__BORLANDC__) || defined (__WATCOMC__) || defined(_MSC_VER) ||                 defined(__ZTC__) || defined(__HIGHC__) || defined(_TURBOC_)
 typedef  long  int   Word32   ;
 typedef  short int   Word16   ;
 typedef  short int   Flag  ;
 #elif defined( __sun)
 typedef short  Word16;
 typedef long  Word32;
 typedef int   Flag;
 #elif defined(__unix__) || defined(__unix)
 typedef short Word16;
 typedef int   Word32;
 typedef int   Flag;
 #elif defined(VMS) || defined(__VMS) 
 typedef short  Word16;
 typedef long  Word32;
 typedef int   Flag;
 #else
 #error  COMPILER NOT TESTED typedef.h needs to be updated, see readme
 #endif

Solution

  • For iOS/tvOS/watchOS, you can use:

    #if (TARGET_OS_IPHONE)
    

    For iOS, you can use:

    #if (TARGET_OS_IOS)
    

    and for MAC OS X:

    #if (TARGET_OS_OSX)
    

    Hope this helps.