File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -113,6 +113,26 @@ extern "C" {
113113 #endif
114114#endif
115115
116+ /* *
117+ * @brief Annotations for nullable and nonnull pointers.
118+ *
119+ * These macros provide compiler hints about pointer validity, improving static analysis and safety.
120+ *
121+ * - **GCC/Clang:** Uses `__attribute__((nullable))` and `__attribute__((nonnull))`
122+ * - **MSVC:** Uses `_Null_terminated_` and `_In_` (though `_In_` is not strictly equivalent to nonnull)
123+ * - **Fallback:** If the compiler does not support these attributes, it defines empty macros.
124+ */
125+ #if defined(__clang__) || defined(__GNUC__)
126+ #define cnullable __attribute__ ((nullable))
127+ #define cnonnull __attribute__ ((nonnull))
128+ #elif defined(_MSC_VER)
129+ #define cnullable _Null_terminated_ // Not a perfect match, but useful for MSVC
130+ #define cnonnull _In_ // MSVC does not have a direct `nonnull` equivalent
131+ #else
132+ #define cnullable
133+ #define cnonnull
134+ #endif
135+
116136// Termination values for regular and wide strings
117137
118138/* *
You can’t perform that action at this time.
0 commit comments