• 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: How are __LITTLE_ENDIAN__ and __BIG_ENDIAN__ defined?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How are __LITTLE_ENDIAN__ and __BIG_ENDIAN__ defined?


  • Subject: Re: How are __LITTLE_ENDIAN__ and __BIG_ENDIAN__ defined?
  • From: Matthew Formica <email@hidden>
  • Date: Wed, 16 Nov 2005 12:20:46 -0800

FYI, you can get a dump of everything that the compiler will #define for you (independent of what your code defines) by typing the following in a Terminal window:

cpp -E -dM /dev/null

Regards,

Matthew Formica
Developer Tools & Cocoa Evangelist
email@hidden

On Nov 16, 2005, at 7:49 AM, Clark Cox wrote:

On 11/16/05, Sean McBride <email@hidden> wrote:
On 2005-11-15 16:27, Eric Albert said:

Also, since only one of them is defined would it be better to use
#if as I did above or should I use #ifdef?

In general, I prefer #if to #ifdef just because that protects you if someone writes code like this:

#if __LITTLE_ENDIAN__
#define __BIG_ENDIAN__ 0
#endif

OTOH, some compilers, like CodeWarrior, will (optionally of course) give
a warning using an undefined macro in an #if test:


Warning : undefined macro '__LITTLE_ENDIAN__' used in #if or #elif conditional
HelloWorld.c line 11 #if __LITTLE_ENDIAN__


I'm not a language lawyer, so I'm not sure if it's defined behaviour to
do an #if test on an undefined macro. No doubt someone will pipe up. :)

No doubt :)

Yes, it is well defined.
"#if UNDEFINED_MACRO"

is the same as:

"#if 0"

--
Clark S. Cox III
email@hidden
http://clarkcox3.livejournal.com/
http://homepage.mac.com/clarkcox3/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40apple.com


This email sent to email@hidden

_______________________________________________ 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
References: 
 >How are __LITTLE_ENDIAN__ and __BIG_ENDIAN__ defined? (From: Dave Thorup <email@hidden>)
 >Re: How are __LITTLE_ENDIAN__ and __BIG_ENDIAN__ defined? (From: Eric Albert <email@hidden>)
 >Re: How are __LITTLE_ENDIAN__ and __BIG_ENDIAN__ defined? (From: "Sean McBride" <email@hidden>)
 >Re: How are __LITTLE_ENDIAN__ and __BIG_ENDIAN__ defined? (From: Clark Cox <email@hidden>)

  • Prev by Date: upgrade problem from 2.0 to 2.2
  • Next by Date: Re: upgrade problem from 2.0 to 2.2
  • Previous by thread: Re: How are __LITTLE_ENDIAN__ and __BIG_ENDIAN__ defined?
  • Next by thread: Can't get Xcode & Perforce to work
  • Index(es):
    • Date
    • Thread