# HG changeset patch # User reimar # Date 1392568202 0 # Node ID fd1feb8ae5fd9fad7cfa98884958d02354270af9 # Parent 18428293fb7f9cad4ff5e443222b4c6fd33c1acc m_struct: use offsetof instead of a custom hack. diff -r 18428293fb7f -r fd1feb8ae5fd m_struct.h --- a/m_struct.h Sun Feb 16 16:30:01 2014 +0000 +++ b/m_struct.h Sun Feb 16 16:30:02 2014 +0000 @@ -19,6 +19,8 @@ #ifndef MPLAYER_M_STRUCT_H #define MPLAYER_M_STRUCT_H +#include + /// \defgroup OptionsStruct Options struct /// \ingroup Options /// An API to manipulate structs using m_option. @@ -52,7 +54,7 @@ * \return The offset of the field in bytes. */ #define M_ST_OFF(struct_type, member) \ - ((void*) &((struct_type*) 0)->member) + ((void*)offsetof(struct_type, member)) /// Get a pointer to a struct field. /** \param struct_p Pointer to the struct.