• 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: CGFloat and 64 Bit
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CGFloat and 64 Bit


  • Subject: Re: CGFloat and 64 Bit
  • From: "Sean McBride" <email@hidden>
  • Date: Mon, 9 Feb 2009 15:10:48 -0500
  • Organization: Rogue Research Inc.

On 2/9/09 11:24 AM, Clark Cox said:

>> Apple's headers inconsistently use #if and #ifdef.
>
>Because #if and #ifdef will both give the proper result in this
>instance (i.e. the GCC compiler either defines __LP64__ to true, or it
>doesn't define it at all), they are interchangeable.
>
>> I recommend:
>>
>> #if defined (__LP64__) && __LP64__
>
>FYI, there is no functional difference between:
>
>#if defined (SOMEMACRO) && SOMEMACRO
>
>and
>
>#if SOMEMACRO
>
>That is, the preprocessor treats any undefined identifier in an '#if'
>or '#elif" as if it were defined to be zero.

I'm not a language lawyer, but I believe the latter is not guaranteed to
evaluate to 0 if the macro is not defined.  However, I imagine 99% of
compilers will evaluate it to 0.  gcc certainly does.  This is the
reason for the existance of -Wundef I believe.

>> which will also not warn with -Wundef.
>
>My original #ifdef won't trigger this warning either

True of course.

>therefore it is
>the best of all options (i.e. it's concise, doesn't trigger warnings,
>and provides the correct result).

True if __LP64__ is either defined to something or not defined at all.
This is currently the case, but I could not find docs guaranteeing
this.  If it's ever defined to 0 then you'd have a problem.  And seeing
how Apple itself sometimes uses #if and sometimes #ifdef I think caution
is advised.

This is rather academic of course... :)

--
____________________________________________________________
Sean McBride, B. Eng                 email@hidden
Rogue Research                        www.rogue-research.com
Mac Software Developer              Montréal, Québec, Canada


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: CGFloat and 64 Bit
      • From: Clark Cox <email@hidden>
References: 
 >CGFloat and 64 Bit (From: "Gerriet M. Denkmann" <email@hidden>)
 >Re: CGFloat and 64 Bit (From: Rob Keniger <email@hidden>)
 >Re: CGFloat and 64 Bit (From: Jean-Daniel Dupas <email@hidden>)
 >Re: CGFloat and 64 Bit (From: Rob Keniger <email@hidden>)
 >Re: CGFloat and 64 Bit (From: Jean-Daniel Dupas <email@hidden>)
 >Re: CGFloat and 64 Bit (From: Rob Keniger <email@hidden>)
 >Re: CGFloat and 64 Bit (From: Jean-Daniel Dupas <email@hidden>)
 >Re: CGFloat and 64 Bit (From: "Sean McBride" <email@hidden>)
 >Re: CGFloat and 64 Bit (From: Clark Cox <email@hidden>)

  • Prev by Date: Question regarding nullified relationship objects
  • Next by Date: Re: Question regarding nullified relationship objects
  • Previous by thread: Re: CGFloat and 64 Bit
  • Next by thread: Re: CGFloat and 64 Bit
  • Index(es):
    • Date
    • Thread