changeset 36768:fd1feb8ae5fd

m_struct: use offsetof instead of a custom hack.
author reimar
date Sun, 16 Feb 2014 16:30:02 +0000
parents 18428293fb7f
children 636c79b71de9
files m_struct.h
diffstat 1 files changed, 3 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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 <stddef.h>
+
 /// \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.