• 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: Interesting preprocessor code behavior
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Interesting preprocessor code behavior


  • Subject: Re: Interesting preprocessor code behavior
  • From: "Clark Cox" <email@hidden>
  • Date: Thu, 3 Jul 2008 13:40:22 -0700

On Thu, Jul 3, 2008 at 10:54 AM, Greg Guerin <email@hidden> wrote:
> Clark Cox wrote:
>
>> #if MY_UNDEFINED_SYMBOL == ONE
>> ...etc...
>
> The OP mentioned the problem was with #elif, which could be significant.

Regardless of whether #if or #elif is used, it is a compiler bug.

> The OP did not mention which version of gcc was used, which could also be
> significant.

Indeed, but that doesn't change the fact that this should work unconditionally.


>
> It was also not mentioned what the order of operands for the fail-case was.
>  DEF==UNDEF could differ from UNDEF==DEF (and would be a bug).
>
> FWIW, the classical way to avoid the problem is:
>  #if (defined(X) && ...expression involving X...)

Only if you want an undefined 'X' to mean something distinct from an
'X' defined to be zero. The standard guarantees that an undefined
identifier in an #if or #elif is identical in every way to a literal
zero (except when being tested with defined()). Any compiler that
doesn't live up to that guarantee is broken, and should have a bug
filed against it.

--
Clark S. Cox III
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: 
 >Re: Interesting preprocessor code behavior (From: Greg Guerin <email@hidden>)

  • Prev by Date: Re: Reordering Tabs with IB 3.0
  • Next by Date: Auto-include date/time
  • Previous by thread: Re: Interesting preprocessor code behavior
  • Next by thread: Came back to this mailing list.. continuation of Re: [Q] Is the 10.4u SDK distributed for the Intel Mac and the PPC Mac different?
  • Index(es):
    • Date
    • Thread