Re: Per-architecture -D options?
Re: Per-architecture -D options?
- Subject: Re: Per-architecture -D options?
- From: Eric Albert <email@hidden>
- Date: Fri, 10 Feb 2006 09:43:15 -0800
On Feb 10, 2006, at 8:56 AM, James Larcombe wrote:
Dave McCaldon wrote:
Is there a way to have architecture specific -D options, for example:
gcc .... -DMY_BIG_ENDIAN_ppc -DMY_LITTLE_ENDIAN_i386
Which will turn into -DMY_BIG_ENDIAN for PPC and -DMY_LITTLE_ENDIAN
for Intel?
I'm trying to avoid having to change any code (we have lots of source
files ...)!
Do you have a prefix file? If so you could use something like this:
#ifdef __LITTLE_ENDIAN__
#define MY_LITTLE_ENDIAN
#endif
and so on...
__LITTLE_ENDIAN__ and __BIG_ENDIAN__ are built-in to GCC I think.
They're actually only built-in to the Apple (originally NeXT) versions
of GCC. I was a bit surprised when I realized they weren't in anyone
else's releases, since they're quite useful. However,
__LITTLE_ENDIAN__ is also defined by ICC on Mac OS X, so I think we've
started at least a miniature trend.
In response to Dave's original question, this should work:
gcc -arch i386 -arch ppc -DMY_BIG_ENDIAN=__BIG_ENDIAN__
-DMY_LITTLE_ENDIAN=__LITTLE_ENDIAN__ ...
as long as your code checks for MY_BIG_ENDIAN and MY_LITTLE_ENDIAN with
#if instead of #ifdef.
Hope this helps,
Eric
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden