29 lines · c
1/* Compile with:2 clang -c -g -arch x86_64h -arch x86_64 -arch i386 fat-test.c3 libtool -static -o libfat-test.a fat-test.o4 5 to generate a dylib instead:6 clang -arch ... -arch ... -arch ... -dynamiclib fat-test.o -o fat-test.dylib7 8 To reduce the size of the fat binary:9 lipo -thin i386 -o fat-test.i386.o fat-test.o 10 lipo -thin x86_64 -o fat-test.x86_64.o fat-test.o 11 lipo -thin x86_64h -o fat-test.x86_64h.o fat-test.o 12 lipo -create -arch x86_64h fat-test.x86_64h.o -arch x86_64 fat-test.x86_64.o -arch i386 fat-test.i386.o -o fat-test.o -segalign i386 8 -segalign x86_64 8 -segalign x86_64h 813 */14#ifdef __x86_64h__15int x86_64h_var;16#elif defined(__x86_64__)17int x86_64_var;18#elif defined(__i386__)19int i386_var;20#elif defined(__ARM_ARCH_7S__)21int armv7s_var;22#elif defined(__ARM_ARCH_7A__)23int armv7_var;24#elif defined(__ARM64_ARCH_8__)25int arm64_var;26#else27#error "Unknown architecture"28#endif29