Skip to content

Instantly share code, notes, and snippets.

@TatsuyaOGth
Created June 18, 2014 13:19
Show Gist options
  • Save TatsuyaOGth/7a6006c9ddecbc3fb655 to your computer and use it in GitHub Desktop.
Save TatsuyaOGth/7a6006c9ddecbc3fb655 to your computer and use it in GitHub Desktop.
Detect reliably Mac OS X, iOS, Linux, Windows in C preprocessor
#ifdef _WIN64
//define something for Windows (64-bit)
#elif _WIN32
//define something for Windows (32-bit)
#elif __APPLE__
#include "TargetConditionals.h"
#if TARGET_OS_IPHONE && TARGET_IPHONE_SIMULATOR
// define something for simulator
#elif TARGET_OS_IPHONE
// define something for iphone
#else
#define TARGET_OS_OSX 1
// define something for OSX
#endif
#elif __linux
// linux
#elif __unix // all unices not caught above
// Unix
#elif __posix
// POSIX
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment