• Testing for presence of Apple platform in C/C++/ObjC code

    Are we running on an Apple platform?
    #ifdef __APPLE__
    #endif
    Prerequisite for other tests
    #ifdef __APPLE__
    // let Apple define 
    // various TARGET_OS_ 
    // constants
    #include  
    #else
    // not on Apple platform
    #define TARGET_OS_MAC 0
    #define TARGET_OS_IPHONE 0
    #endif
    Are we running on Mac OS X?
    #if TARGET_OS_MAC && !TARGET_OS_IPHONE
    ….
    #endif
    Are we running on an iOS device?
    #if TARGET_OS_IPHONE
    ….
    #endif
    // updated on Oct13 2010, previous method was flawed. sorry everyone!

    Tags: , , ,

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    *

    You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>