Skip to content

Instantly share code, notes, and snippets.

@steipete
Created February 25, 2015 23:22
Show Gist options
  • Save steipete/d9f519858fe5fb5533eb to your computer and use it in GitHub Desktop.
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.
// 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
@samjarman
Copy link

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