site_archiver@lists.apple.com Delivered-To: darwin-kernel@lists.apple.com On Mar 8, 2008, at 12:34 PM, mm w wrote: + i discovered nothing it was just a simple example to illustrate an empiric way To find out what the preprocessor defines, try this: echo | gcc -arch x86_64 -dD -E - | less I do not know if you tried to use humour, but very bad I thought it was funny. -Dave Thank you #include <stdio.h> /* main.c */ int main(void) { #if ARCH_X86_64 puts("hello world 64!"); #else puts("hello world!"); #endif return 0; } /* EOF */ $ ./main-i386 hello world! $ ./main-x86_64 hello world 64! $ ./main hello world 64! ps or activity monitor or, as you have discovered, printf. 2 - is it possible to force one arch to be loaded rather than the default one? Check the checkbox in finder, if it's a GUI application, or: man arch -- Terry -- -mmw _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-kernel mailing list (Darwin-kernel@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-kernel/dfe%40tgwbd.org _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-kernel mailing list (Darwin-kernel@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-kernel/site_archiver%40lists.a... + the question was not related to an app Yes, which is why Terry told you to man arch. RTFM and you'll clearly get the answer about how you can force the OS to run a particular architecture. I think Terry read your example wrong. I know I did the first time through. You do not need to define ARCH_X86_64 yourself. It is already the case that __LP64__ will be defined for 64-bit (PPC or Intel) and not for 32-bit (PPC or Intel). It is also the case that __i386__ will be defined for i386 and __x86_64__ for x86-64 and so on and so forth. There's other stuff like __BIG_ENDIAN__ or __LITTLE_ENDIAN__. In general you should use macros like __BIG_ENDIAN__/__LITTLE_ENDIAN__ and __LP64__/!__LP64__ in preference to architecture-specific macros unless you are really writing architecture-specific code (e.g. inline assembler). So when he said you can use printf what he meant was that you can use preprocessor definitions to determine this because naturally your program is compiled once for each architecture and lipo'd together. Therefore the built-in preprocessor definitions are necessarily different. Even if you use gcc ... -arch i386 -arch x86_64 ... this will still be the case. That tells gcc to run the preprocessor only (-E) on the file "-" (which is short for stdin) for the given architecture and to dump the preprocessor definitions that are defined. Since the source file is one empty line (provided by echo ) you will only see what is built- in to the compiler plus what is defined on the command-line. On Fri, Mar 7, 2008 at 10:24 PM, Terry Lambert <tlambert@apple.com> wrote: On Mar 7, 2008, at 5:06 PM, mm w wrote: /* cc -ansi -Wall -O3 -arch i386 -DARCH_X86_64=0 main.c -o main-i386 cc -ansi -Wall -O2 -arch x86_64 -DARCH_X86_64=1 main.c -o main- x86_64 lipo -create -arch i386 main-i386 -arch x86_64 main-x86_64 -o main */ 1 - is there a way to know which arch/img has been loaded? This email sent to dfe@tgwbd.org This email sent to site_archiver@lists.apple.com