• 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: Block variable syntax related question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Block variable syntax related question


  • Subject: Re: Block variable syntax related question
  • From: Jens Alfke <email@hidden>
  • Date: Fri, 09 Sep 2011 14:47:55 -0700


On Sep 9, 2011, at 12:38 PM, Bavarious wrote:

In this particular case, the conditional operator promotes the second and third operands to int as specified in the C99 standard. This means that

[obj compare:@"foo"] == 0 ? YES : NO

is an int _expression_, not a BOOL one. The block variable has return type BOOL and the block literal has inferred return type int, hence the compiler error.

I think this stems from BOOL being merely a typedef for ‘signed char’, not a real type. This causes problems elsewhere too (for example, the sign bit means a one-bit wide BOOL bitfield member won’t work. That one’s fun to debug.)

Bit of a tangent, but as C’s had a native ‘bool’ type for a decade+ now, is there some reason Cocoa can’t switch to using it instead of BOOL? Like, make BOOL a typedef for bool? Or would that introduce too many compatibility problems? Or short of that, would there be a problem if an app were to switch to using bool in its own code?

—Jens
 _______________________________________________
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

  • Follow-Ups:
    • Re: Block variable syntax related question
      • From: Chris Hanson <email@hidden>
    • Re: Block variable syntax related question
      • From: Bavarious <email@hidden>
    • Re: Block variable syntax related question
      • From: Scott Ribe <email@hidden>
    • Re: Block variable syntax related question
      • From: Sean McBride <email@hidden>
References: 
 >Block variable syntax related question (From: David Hoerl <email@hidden>)
 >Re: Block variable syntax related question (From: Bavarious <email@hidden>)

  • Prev by Date: Automatically adding new files to the project
  • Next by Date: Re: Automatically adding new files to the project
  • Previous by thread: Re: Block variable syntax related question
  • Next by thread: Re: Block variable syntax related question
  • Index(es):
    • Date
    • Thread