X-Git-Url: https://git.distorted.org.uk/~mdw/sod/blobdiff_plain/71ecc48e20c8651175b16f37ee66ca08a36cc1c6..a07d8d005f69c0f9f5da2e09c6ee39cb1e1801aa:/sod.h?ds=inline diff --git a/sod.h b/sod.h index cb56244..999c30e 100644 --- a/sod.h +++ b/sod.h @@ -84,6 +84,19 @@ struct sod_chain { #define SOD_XCHAIN(chead, p) ((char *)(p) + (p)->_vt->_off_##chead) +/* --- @SOD_OFFSETDIFF@ --- * + * + * Arguments: @type@ = a simple (i.e., declaratorless) type name + * @mema, memb@ = members of @type@ + * + * Returns: The relative offset from @mema@ to @memb@, as a @ptrdiff_t@. + * + * Use: Computes a signed offset between structure members. + */ + +#define SOD_OFFSETDIFF(type, mema, memb) \ + ((ptrdiff_t)offsetof(type, memb) - (ptrdiff_t)offsetof(type, mema)) + /* --- @SOD_ILAYOUT@ --- * * * Arguments: @cls@ = name of a class