Skip to content

Instantly share code, notes, and snippets.

@dbremner
Last active July 13, 2023 23:03
Show Gist options
  • Save dbremner/c4725f83a5861e1fbcc56b2f5dca28e1 to your computer and use it in GitHub Desktop.
Save dbremner/c4725f83a5861e1fbcc56b2f5dca28e1 to your computer and use it in GitHub Desktop.
Macro for generating nullability typedefs
#ifndef NULLABILITY_TYPEDEFS_H
#define NULLABILITY_TYPEDEFS_H
#define MAKE_NULLABILITY_TYPEDEFS(type, name) \
typedef const type *const _Nonnull name##_pure_ptr; \
typedef const type *_Nonnull name##_const_ptr; \
typedef type *_Nonnull name##_ptr; \
typedef type *_Nullable name##_null_ptr; \
typedef const type *const _Nullable name##_pure_null_ptr; \
typedef type *_Nonnull *_Nonnull name##_ptr_ptr; \
typedef type *_Nullable *_Nullable name##_null_ptr_ptr;
MAKE_NULLABILITY_TYPEDEFS(char, char)
MAKE_NULLABILITY_TYPEDEFS(struct timeval, timeval)
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment