From 9dfc7daf79a855cb638baf99d3cb7e3833bf99a5 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 12 Jul 2013 18:40:08 +0200 Subject: m_struct: try to be more standard C The main problem is that this m_struct stuff uses pointers for offsets (why...), so we mangle it by intptr_t. This stuff really should use ints (or in theory ptrdiff_t) for offsets, but changing it would be too much effort, and hopefully this m_struct stuff will go away and replaced by the common option parser mechanism instead. Shuts up warnings on Windows. Patch suggested by jon_y and rossy on IRC. --- core/m_struct.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/core/m_struct.h b/core/m_struct.h index 6ddd221f1b..b0b0afe23d 100644 --- a/core/m_struct.h +++ b/core/m_struct.h @@ -19,6 +19,9 @@ #ifndef MPLAYER_M_STRUCT_H #define MPLAYER_M_STRUCT_H +#include +#include + #include "core/bstr.h" /// \defgroup OptionsStruct Options struct @@ -46,15 +49,12 @@ typedef struct m_struct_st { } m_struct_t; -// From glib.h (modified ;-) - /// Get the offset of a struct field. /** \param struct_type Struct type. * \param member Name of the field. * \return The offset of the field in bytes. */ -#define M_ST_OFF(struct_type, member) \ - ((void*) &((struct_type*) 0)->member) +#define M_ST_OFF (void *)(uintptr_t)offsetof /// Get a pointer to a struct field. /** \param struct_p Pointer to the struct. @@ -62,7 +62,7 @@ typedef struct m_struct_st { * \return Pointer to the struct field. */ #define M_ST_MB_P(struct_p, struct_offset) \ - ((void *)((char *)(struct_p) + (unsigned long)(struct_offset))) + ((void *)((char *)(struct_p) + (uintptr_t)(struct_offset))) /// Access a struct field at a given offset. /** \param member_type Type of the field. -- cgit v1.2.3