Created
February 25, 2015 23:22
-
-
Save steipete/d9f519858fe5fb5533eb to your computer and use it in GitHub Desktop.
Want nullability right away? This will degrade gracefully until you can drop Xcode 6.1/Xcode 6.2.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Xcode 6.3 defines new language features to declare nullability | |
#if __has_feature(nullability) | |
#define PSPDF_ASSUME_NONNULL_BEGIN _Pragma("clang assume_nonnull begin") | |
#define PSPDF_ASSUME_NONNULL_END _Pragma("clang assume_nonnull end") | |
#define ps_nullable nullable | |
#define ps_nonnull nonnull | |
#define ps_null_unspecified null_unspecified | |
#define ps_null_resettable null_resettable | |
#define __ps_nullable __nullable | |
#define __ps_nonnull __nonnull | |
#define __ps_null_unspecified __null_unspecified | |
#else | |
#define PSPDF_ASSUME_NONNULL_BEGIN | |
#define PSPDF_ASSUME_NONNULL_END | |
#define ps_nullable | |
#define ps_nonnull | |
#define ps_null_unspecified | |
#define ps_null_resettable | |
#define __ps_nullable | |
#define __ps_nonnull | |
#define __ps_null_unspecified | |
#endif |
In xcode 7, I get Macro name is a reserved identifier
with the macros starting with __
. Any ideas?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Prefix-less defines could cause issues with some
__attribute__
attributes, for example with:Last line will produce error. So, existing codebases must adopt new nullability features or use something old like
__attribute__((nonnull()))
. Interesting, how will they interact if some argument will be specified as nullable while having__attribute__((nonnull()))
.