Created
November 17, 2020 15:16
-
-
Save Adobe-Android/eff11494bb8580fa13145d89791b4a84 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using std::cout; | |
using std::string; | |
int main() { | |
// Uses C++11 features. | |
string os{}; | |
// Detect operating system. | |
#if defined(__linux__) | |
os = "Linux"; | |
#if defined(__ANDROID__) | |
os = "Android"; | |
#endif | |
#elif defined(_WIN32) | |
os = "Windows"; | |
#elif defined(__APPLE__) | |
// Detect iOS before macOS (__MACH__ is also defined for iOS) | |
#if defined(IPHONE) | |
os = "iOS"; | |
#elif defined(__MACH__) | |
os = "macOS"; | |
#endif | |
#elif defined(__EMSCRIPTEN__) | |
os = "Emscripten"; | |
#else | |
os = "Unable to determine operating system"; | |
#endif | |
cout << os; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment