[MPlayer-cvslog] r36864 - trunk/m_struct.h

reimar subversion at mplayerhq.hu
Sun Feb 16 17:30:03 CET 2014


Author: reimar
Date: Sun Feb 16 17:30:02 2014
New Revision: 36864

Log:
m_struct: use offsetof instead of a custom hack.

Modified:
   trunk/m_struct.h

Modified: trunk/m_struct.h
==============================================================================
--- trunk/m_struct.h	Sun Feb 16 17:30:01 2014	(r36863)
+++ trunk/m_struct.h	Sun Feb 16 17:30:02 2014	(r36864)
@@ -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 @@ typedef struct m_struct_st {
  *  \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.


More information about the MPlayer-cvslog mailing list