• 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: Clang __has_feature check for new 'nullable' language extensions?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Clang __has_feature check for new 'nullable' language extensions?


  • Subject: Re: Clang __has_feature check for new 'nullable' language extensions?
  • From: Jens Alfke <email@hidden>
  • Date: Thu, 12 Feb 2015 09:18:04 -0800


On Feb 11, 2015, at 11:55 PM, Roland King <email@hidden> wrote:

I’m guessing it’s
__has_feature( nullability )

That works — thanks!

So the magic invocation I’m putting in my header files (after the #includes) is:

#if __has_feature(nullability) // Xcode 6.3+
#pragma clang assume_nonnull begin
#else
#define nullable
#define __nullable
#endif

… interface declarations go here…

#if __has_feature(nullability)
#pragma clang assume_nonnull end
#endif

In property declarations you'll need to make “nullable” the last meta-attribute, otherwise you’ll get syntax errors in earlier versions of Xcode; so for example “(readonly, nonatomic, nullable)” works but “(readonly, nullable, nonatomic)” is a syntax error because in Xcode 6.1 the parser will see two adjacent commas.

[This is working well, but in converting my interfaces I found a nasty compiler bug that I’m about to submit to Apple — if you declare multiple properties on a single line, adding the (nullable) attribute will cause the parser to lock up in an infinite loop:
@property (readonly, nullable) id a, b, c;  // don’t do this!
I spent an hour or so with my MBP’s fan running full speed before figuring out which exact line triggered this.]

—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: Clang __has_feature check for new 'nullable' language extensions?
      • From: Chris Lattner <email@hidden>
References: 
 >Clang __has_feature check for new 'nullable' language extensions? (From: Jens Alfke <email@hidden>)
 >Re: Clang __has_feature check for new 'nullable' language extensions? (From: Roland King <email@hidden>)

  • Prev by Date: Re: Clang __has_feature check for new 'nullable' language extensions?
  • Next by Date: Re: Clang __has_feature check for new 'nullable' language extensions?
  • Previous by thread: Re: Clang __has_feature check for new 'nullable' language extensions?
  • Next by thread: Re: Clang __has_feature check for new 'nullable' language extensions?
  • Index(es):
    • Date
    • Thread