Created
September 14, 2012 17:20
-
-
Save TooTallNate/3723332 to your computer and use it in GitHub Desktop.
Detecting arch of a fat binary using the preprocessor
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 () { | |
if (sizeof(int*) == 4) { | |
printf("ia32\n"); | |
} | |
if (sizeof(int*) == 8) { | |
printf("x64\n"); | |
} | |
return 0; | |
} |
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
$ gcc -o arch-test arch-test.c -arch i386 -arch x86_64 | |
$ ./arch-test | |
x64 | |
$ arch -32 ./arch-test | |
ia32 | |
$ arch -64 ./arch-test | |
x64 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment