stddef: add typeof macro

This commit is contained in:
anna 2021-08-01 17:06:08 +02:00
parent 3aa2c53893
commit abb526f655
Signed by: fef
GPG key ID: EC22E476DC2D3D84

View file

@ -12,9 +12,18 @@
* @param member: The member inside the struct to the offset of.
* @returns The offset of `member` reelative to `type`, casted to a `size_t`.
*/
#define offsetof(type, member) ((size_t)&((type *)0)->member)
#define offsetof(type, member) __builtin_offsetof(type, member)
#endif /* offsetof */
#ifndef typeof
/**
* @brief Get the type `expr` evaluates to (for generic macros).
*
* @param expr Expression to get the type of
*/
#define typeof(expr) __typeof(expr)
#endif
#ifndef NULL
/** The `NULL` pointer. */
#define NULL ((void *)0)