Skip to content

Instantly share code, notes, and snippets.

@deltheil
Created January 12, 2012 17:53
Show Gist options
  • Save deltheil/1602054 to your computer and use it in GitHub Desktop.
Save deltheil/1602054 to your computer and use it in GitHub Desktop.
Preprocessor: detect mobile platform (iOS vs Android)
/**
* NOTES:
* - iOS: the useful macros are defined within TargetConditionals.h
* - Android:
* - with Android.mk file(s) and the 'ndk-build' script (aka vanilla way),
* ANDROID is predefined (see -DANDROID extra C flag),
* - with the Android Standalone Toolchain __ANDROID__ is predefined instead
*/
#if defined(__APPLE__)
#include <TargetConditionals.h>
#if TARGET_OS_IPHONE
#define __SYSNAME_IOS__
#define SYSNAME "ios"
#endif
#elif defined(ANDROID) || defined(__ANDROID__)
#define __SYS_ANDROID__
#define SYSNAME "android"
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment