diff options
| author | nechda <[email protected]> | 2025-03-18 08:32:32 +0300 |
|---|---|---|
| committer | nechda <[email protected]> | 2025-03-18 08:51:07 +0300 |
| commit | 39355151af244681ffa988fda4b79f3f01da8797 (patch) | |
| tree | 885d8b18094f798672d668759aba3f340b137297 | |
| parent | c553455f6bfb95fdf43c1edd64283cce307c9536 (diff) | |
Add Y_NONNULL attribute macro
commit_hash:140767fba3ddf262d702b06bc0bade2616e5a317
| -rw-r--r-- | util/system/compiler.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/util/system/compiler.h b/util/system/compiler.h index 499e432eee4..6a8239d1575 100644 --- a/util/system/compiler.h +++ b/util/system/compiler.h @@ -716,3 +716,22 @@ Y_FORCE_INLINE void DoNotOptimizeAway(const T&) = delete; #else #define Y_RETURNS_NONNULL #endif + +/** + * @def Y_NONNULL + * + * The nonnull attribute indicates that some function parameters must not be null. + * + * @see + * GCC: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-nonnull-function-attribute + * Clang: https://clang.llvm.org/docs/AttributeReference.html#id15 + * + * @code + * void func(char* Y_NONNULL arr, size_t len); + * @endcode + */ +#if Y_HAVE_ATTRIBUTE(nonnull) + #define Y_NONNULL __attribute__((nonnull)) +#else + #define Y_NONNULL +#endif |
