It lives!
[sod] / sod.h
diff --git a/sod.h b/sod.h
index cb56244..999c30e 100644 (file)
--- 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