• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: programmatically determining if the machine is intel or not
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: programmatically determining if the machine is intel or not


  • Subject: Re: programmatically determining if the machine is intel or not
  • From: Greg Hurrell <email@hidden>
  • Date: Wed, 17 May 2006 15:00:34 +0200

El 17/05/2006, a las 14:35, Håkan Waara escribió:

That doesn't seem to be a runtime check; it only determines what the person who compiled the code was running, right?

Well, no, in a Universal binary the code when run on an Intel machine is equivalent to:


BOOL isIntel = YES;
if (isIntel)
	// the compiler probably optimizes away all but the following line
	NSLog(@"is Intel");
else
	NSLog(@"is not Intel");

And on a PowerPC it is equivalent to:

BOOL isIntel = NO;
if (isIntel)
	NSLog(@"is Intel");
else
	// the compiler probably optimizes away all but the following line
	NSLog(@"is not Intel");

So it's a compile-time check but it has a run-time effect. I imagine that when running under Rosetta it "isIntel" will be NO. The API- based suggestions already posted a no doubt better (in any case Apple recommends against relying on the __i386__ and __ppc__ macros); this was just a quick-and-dirty alternative.

Cheers,
Greg


Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
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

References: 
 >programmatically determining if the machine is intel or not (From: Jonathan Sand <email@hidden>)
 >Re: programmatically determining if the machine is intel or not (From: Greg Hurrell <email@hidden>)
 >Re: programmatically determining if the machine is intel or not (From: Håkan Waara <email@hidden>)

  • Prev by Date: Re: A word of caution...
  • Next by Date: Re: programmatically determining if the machine is intel or not
  • Previous by thread: Re: programmatically determining if the machine is intel or not
  • Next by thread: Re: programmatically determining if the machine is intel or not
  • Index(es):
    • Date
    • Thread