Created
February 25, 2018 05:12
-
-
Save Yoone/ca9359d7489c3c76de14b042cf0287ad to your computer and use it in GitHub Desktop.
Find out a machine's CPU architecture in C
This file contains 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 <stdio.h> | |
int main(void) | |
{ | |
/* | |
* AMD64 | |
*/ | |
#if defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64) | |
printf("AMD64\n"); | |
#endif | |
/* | |
* ARM (32 bits I presume) | |
*/ | |
#if defined(__arm__) | |
printf("ARM 32bits\n"); | |
#endif | |
/* | |
* ARM64 | |
*/ | |
#if defined(__aarch64__) | |
printf("ARM64\n"); | |
#endif | |
/* | |
* x86 | |
*/ | |
#if defined(i386) || defined(__i386) || defined(__i386__) | |
printf("x86\n"); | |
#endif | |
#ifdef __i486__ | |
printf("__i486__\n"); | |
#endif | |
#ifdef __i586__ | |
printf("__i586__\n"); | |
#endif | |
#ifdef __i686__ | |
printf("__i686__\n"); | |
#endif | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment