Skip to content

Instantly share code, notes, and snippets.

@while0pass
Forked from TatsuyaOGth/common.h
Created February 23, 2021 08:15
Show Gist options
  • Save while0pass/570892c26fa126cb5544378054c80ecc to your computer and use it in GitHub Desktop.
Save while0pass/570892c26fa126cb5544378054c80ecc 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