• 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: Lee Falin <email@hidden>
  • Date: Wed, 17 May 2006 14:18:06 -0400

How is that exactly? I've never heard of powerPC running in little endian mode.

On May 17, 2006, at 10:53 AM, Shawn Erickson wrote:


On May 17, 2006, at 6:05 AM, Lee Falin wrote:

"Does anyone know of a way to programmatically determine whether ones Mac code is running on PowerPC or Intel hardware?"

An easy way to do this is to use the NSHostByteOrder function.

This will return the correct value for you for byte swapping purposes as well. The problem with trying to just "read" the processor name as some other posts have mentioned, is that those techniques don't take Rosetta into account.

For example if your app is running on an Intel machine, but for some reason the user, (or you for testing purposes) runs it in powerpc mode under Rosetta, you would want it to report as running under PowerPC rather than intel.

An example of how to do this:

if(NSHostByteOrder() == NS_BigEndian)
{
	NSLog(@"is running in powerPC mode");
}
else
{
	NSLog(@"is running in intel mode");
}

This is a little fragile since in theory PPC can run in either endian mode.


-Shawn

_______________________________________________ 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
  • Follow-Ups:
    • Re: programmatically determining if the machine is intel or not
      • From: Nick Zitzmann <email@hidden>
References: 
 >Re: programmatically determining if the machine is intel or not (From: Lee Falin <email@hidden>)
 >Re: programmatically determining if the machine is intel or not (From: Shawn Erickson <email@hidden>)

  • Prev by Date: Re: How can I create a PDF document from a string in a non-GUI application?
  • Next by Date: Re: Should I retain/release IBOutlet?
  • 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