Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
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" rMBP, iPad 4, iPhone 5s
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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
Steam Developing For OSX Lion [Proof] polo3400 Mac OS X 10.7 Lion 8 May 21, 2011 01:26 PM
10.5 Install mess USB, PPC vs Intel, override installer help? spacepower7 PowerPC Macs 12 Nov 15, 2010 05:55 PM
reinstalling OSX for my PPC on an Intel machine NakedLunch PowerPC Macs 6 Jun 17, 2010 11:21 AM
real world speed tests for Word on PPC, Intel Macs and older Macs? California Mac Basics and Help 9 Jan 23, 2007 03:00 PM
Timeline For Mac OSX PPC jericho53 OS X 6 Mar 27, 2006 07:46 PM


All times are GMT -5. The time now is 06:04 AM.

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

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