From 29d181c1137ff9fbfaac4efae3846ad8e5c8d76f Mon Sep 17 00:00:00 2001 From: Patrick Pelissier Date: Sat, 17 Feb 2018 19:19:09 +0100 Subject: [PATCH] Add macro M_CTYPE_FROM_FIELD like M_TYPE_FROM_FIELD but for const pointer. --- m-core.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/m-core.h b/m-core.h index 0f96bcdf..5bbccffa 100644 --- a/m-core.h +++ b/m-core.h @@ -1202,6 +1202,8 @@ #define M_TYPE_FROM_FIELD(type, ptr, field_type, field) \ ((type *)(void*)( (char *)M_ASSIGN_CAST(field_type*, (ptr)) - offsetof(type, field) )) +#define M_CTYPE_FROM_FIELD(type, ptr, field_type, field) \ + ((const type *)(const void*)( (const char *)M_ASSIGN_CAST(const field_type*, (ptr)) - offsetof(const type, field) )) /************************************************************/