diff --git a/include/malunal/type.h b/include/malunal/type.h index 734ee70..2a24a35 100644 --- a/include/malunal/type.h +++ b/include/malunal/type.h @@ -288,4 +288,28 @@ _Static_assert( typedef const name##_t* name##_iptr_t; \ struct name +/** + * @def define_union + * @brief Defines a union and its pointer types. + * @details This simplifies the way we typically define our unions, in which + * we define the union itself and type definitions for the mutable + * and immutable pointers to that union. + * @param name The name of the union. + */ +#define define_union(name) \ + typedef union name name##_t; \ + typedef name##_t* name##_mptr_t; \ + typedef const name##_t* name##_iptr_t; \ + union name + +/** + * @def define_enum + * @brief Defines an enumeration. + * @details This simplifies the way we typically define our enumerations. + * @param name The name of the structure. + */ +#define define_enum(name) \ + typedef enum name name##_t; \ + enum name + #endif /* MALUNAL_TYPES_HEADER */