Saturday, June 13, 2015

Re: __has_feature() for nullability?

Am 14.06.2015 um 00:30 schrieb Michael Hackett <mhackett@randomsample.org>:

> I'm not sure, but from what I've read, I believe the non-underscore version is only for use in Obj-C declarations (methods, properties), where the double-underscore is for C declarations, including functions and variables (local, global, or, I would expect, instance).
>
> I don't know why there would be an issue with multiple levels of pointers in a method declaration. Perhaps when everyone's recovered from WWDC, someone else will chime in to help out. :-)

That's how I understood it as well. Basically, nullable/nonnull is invalid outside of a method declaration. However, it seems that it's also invalid in something like

- (void)foo: (nullable id*)foo;

as that gives:

error: nullability keyword 'nullable' cannot be applied to
multi-level pointer type 'id *'

If you do

- (void)foo: (id *nullable)foo;

it gets confused:

error: expected ')'

But both work fine with __nullable. Maybe a bug?

Oh, another very nasty thing I noticed:
glibc also uses __nullable, but it takes a parameter. This means it's not possible to write portable code that uses __nullable :/. Maybe it would be wiser to just make nullable without the __ a keyword and not have __nullable and nullable?

--
Jonathan
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Objc-language mailing list (Objc-language@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/objc-language/anirudha.k.cpp1%40blogger.com

This email sent to anirudha.k.cpp1@blogger.com

No comments:

Post a Comment