Skip to content

Commit

Permalink
Add macro versions of nullability annotations.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 707923083
Change-Id: I169eca5668aa330df62b3120525cf9a401f3959a
  • Loading branch information
Abseil Team authored and copybara-github committed Dec 19, 2024
1 parent 8dfa6b7 commit cd9dd42
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions absl/base/nullability.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,4 +281,26 @@ ABSL_NAMESPACE_END
#define ABSL_NULLABILITY_COMPATIBLE
#endif

// ABSL_NONNULL
// ABSL_NULLABLE
// ABSL_NULLABILITY_UNKNOWN
//
// These macros are analogues of the alias template nullability annotations
// above.
//
// Example:
// int* ABSL_NULLABLE foo;
// Is equivalent to:
// absl::Nullable<int*> foo;
#if defined(__clang__) && !defined(__OBJC__) && \
ABSL_HAVE_FEATURE(nullability_on_classes)
#define ABSL_NONNULL _Nonnull
#define ABSL_NULLABLE _Nullable
#define ABSL_NULLABILITY_UNKNOWN _Null_unspecified
#else
#define ABSL_NONNULL
#define ABSL_NULLABLE
#define ABSL_NULLABILITY_UNKNOWN
#endif

#endif // ABSL_BASE_NULLABILITY_H_

0 comments on commit cd9dd42

Please sign in to comment.