Re: Determining how the app is run (intel/ppc/rosetta/os version)?
Re: Determining how the app is run (intel/ppc/rosetta/os version)?
- Subject: Re: Determining how the app is run (intel/ppc/rosetta/os version)?
- From: "Finlay Dobbie" <email@hidden>
- Date: Fri, 26 May 2006 21:26:26 +0100
On 26/05/06, Gerben Wierda <email@hidden> wrote:
My app contains:
x86 binary compiled with gcc 4 against 10.4 SDK
ppc binary compiled with gcc 3 against the 10.3 SDK to make sure it is
compatible with 10.3 on ppc
...
So, I want to make sure that the app
- exits with a warning when run in rosetta on 10.4.6
- exits with a warning when run natively on 10.4.4-10.4.6 (assuming
that 10.4.7 will be OK again and I have good reason to hope so)
...
Basically, there is a point to detect arch at runtime. Because 10.4.6
on intel is problematic, while 10.4.6 on ppc is not. And this is a
runtime call, I cannot detect that at compile time, obviously.
Yes, you can, because the result is determined at compile time. You
have an x86 binary, which can only run on x86, and the compiler knows
it's generating an x86 binary at compile time. You have a ppc binary,
which can only run on ppc (either native or in Rosetta), and the
compiler knows it's generating a ppc binary at compile time.
So, do something like this (code typed in Mail, demonstration purposes only):
long systemVersion = 0;
OSStatus err = Gestalt(gestaltSystemVersion, &systemVersion);
#ifdef __i386__
if (systemVersion >= 0x1044 && systemVersion <= 0x1046)
// display warning
#else
int ret = 0;
size_t sz = sizeof(ret);
if (sysctlbyname("sysctl.proc_native", &ret, &sz, NULL, 0) == 0 && ret
== 1 && systemVersion == 0x1046)
// display warning
#endif
-- Finlay
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden