Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jun 3, 2006, 07:22 PM   #1
AussieSusan
macrumors member
 
Join Date: May 2006
Location: Melbourne, Australia
Predefined macros for OSX PPC/Intel

(Couldn't find this elsewhere - pointers please if I've missed something).

I'm trying to port some software from UNIX to my MAC and some of the header files contain a whole bunch of tests for various predefined macros to determine the environment and its capabilities (OS, big/little endian, processor type etc.)

What are the predefined macros that are available within GCC and XCode that can be used to differentiate OSX from other OS's, and Intel from PPC processors?

Thanks

Susan
AussieSusan is offline   0 Reply With Quote
Old Jun 3, 2006, 07:35 PM   #2
GeeYouEye
macrumors 68000
 
GeeYouEye's Avatar
 
Join Date: Dec 2001
Location: State of Denial
Send a message via AIM to GeeYouEye Send a message via Yahoo to GeeYouEye
Not sure, as most of the stuff I've coded isn't arch-specific, but I'm pretty sure you can find the answer in the Universal Binary Porting Guide.
__________________
I bring order to chaos. You are in chaos Windows, you are the contradiction, a bug wishing to be an OS.
Visit Softyards Software
NEW DEFINITION OF GEEK
Like politics, free speech, computers, entertainment, and more? Join us at Wordforge.net
GeeYouEye is offline   0 Reply With Quote
Old Jun 4, 2006, 02:03 AM   #3
AussieSusan
Thread Starter
macrumors member
 
Join Date: May 2006
Location: Melbourne, Australia
Answer to my own question

Thanks GeeYouEye - that started me on the right course.

Found the answer - cpp can tell you itself by typing:

cpp -dM
^D

at a terminal prompt. It will list out a whole lot of "#define..." statements.

Hope this helps someone else.

Cheers

Susan
AussieSusan is offline   0 Reply With Quote
Old Dec 27, 2007, 08:25 AM   #4
rezwits
macrumors regular
 
Join Date: Jul 2007
Location: Las Vegas
Send a message via ICQ to rezwits Send a message via AIM to rezwits Send a message via MSN to rezwits Send a message via Yahoo to rezwits Send a message via Skype™ to rezwits
Yeah that kinda works except it's just "your own current machine running" specific. Be nice to have a list like this http://msdn2.microsoft.com/en-us/lib...ay(VS.80).aspx

Thanks
rezwits is offline   0 Reply With Quote
Old Dec 27, 2007, 09:34 AM   #5
gnasher729
macrumors G5
 
gnasher729's Avatar
 
Join Date: Nov 2005
Quote:
Originally Posted by AussieSusan View Post
(Couldn't find this elsewhere - pointers please if I've missed something).

I'm trying to port some software from UNIX to my MAC and some of the header files contain a whole bunch of tests for various predefined macros to determine the environment and its capabilities (OS, big/little endian, processor type etc.)

What are the predefined macros that are available within GCC and XCode that can be used to differentiate OSX from other OS's, and Intel from PPC processors?

Thanks

Susan
Go to developer.apple.com, then type "predefined macros" into the search box.
gnasher729 is offline   0 Reply With Quote
Old Dec 27, 2007, 11:33 AM   #6
kainjow
Moderator emeritus
 
kainjow's Avatar
 
Join Date: Jun 2000
You shouldn't be concerned with whether your code is running on a PPC or Intel, but rather on a little vs big endian processor. Say the iPhone SDK comes out. You don't want a third if-else for ARM, you just need to detect its little endian processor.

Regarding detecting an OS, Mac OS X's GCC uses a __APPLE__ macro, and windows.h uses a WIN32 macro.

Last edited by kainjow; Dec 27, 2007 at 02:23 PM.
kainjow is offline   0 Reply With Quote
Old Dec 27, 2007, 02:16 PM   #7
Krevnik
macrumors 68020
 
Krevnik's Avatar
 
Join Date: Sep 2003
Quote:
Originally Posted by kainjow View Post
You shouldn't be concerned with whether your code is running on a PPC or Intel, but rather on a little vs big endian processor. Say the iPhone comes out. You don't want a third if-else for ARM, you just need to detect its little endian processor.

Regarding detecting an OS, Mac OS X's GCC uses a __APPLE__ macro, and windows.h uses a WIN32 macro.
In addition, the Universal Binary porting guide will likely mention this, but Apple provides macros for handling data from a specific endian format into the native format and back.

For /most/ purposes, this along with standard POSIX network byte-swapping APIs will probably get your most of the way past most of the arch differences between OS X PPC, and OS X Intel.
__________________
iMac 2013 27", 13" 2012 rMBP, iPad Air, iPhone 6
Krevnik is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Cant file share between ppc and intel. Intelligent PowerPC Macs 6 May 20, 2014 08:45 AM
Will Intel share PPC's fate? RedCroissant PowerPC Macs 66 Oct 11, 2013 07:53 AM
Tiger Retail disks and PPC vs. Intel mccjim12 PowerPC Macs 17 Sep 4, 2013 11:38 AM
Creating bootable images for PPC and Intel SamEB OS X 3 Jun 14, 2013 09:44 AM
PPC better than Intel for PPC apps? Woodcrest64 PowerPC Macs 14 Nov 16, 2012 01:04 PM

Forum Jump

All times are GMT -5. The time now is 11:50 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC