stddef: add typeof macro
This commit is contained in:
parent
3aa2c53893
commit
abb526f655
1 changed files with 10 additions and 1 deletions
|
@ -12,9 +12,18 @@
|
||||||
* @param member: The member inside the struct to the offset of.
|
* @param member: The member inside the struct to the offset of.
|
||||||
* @returns The offset of `member` reelative to `type`, casted to a `size_t`.
|
* @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 */
|
#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
|
#ifndef NULL
|
||||||
/** The `NULL` pointer. */
|
/** The `NULL` pointer. */
|
||||||
#define NULL ((void *)0)
|
#define NULL ((void *)0)
|
||||||
|
|
Loading…
Reference in a new issue