summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-07-12 18:40:08 +0200
committerwm4 <wm4@nowhere>2013-07-12 18:40:08 +0200
commit9dfc7daf79a855cb638baf99d3cb7e3833bf99a5 (patch)
tree4f319d2c9c80a6ef98666b4edeadcb6af2e5bee3
parentaa3b8c8fe704bc732feccbea84f8a725ee3b9acd (diff)
downloadmpv-9dfc7daf79a855cb638baf99d3cb7e3833bf99a5.tar.bz2
mpv-9dfc7daf79a855cb638baf99d3cb7e3833bf99a5.tar.xz
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.
-rw-r--r--core/m_struct.h10
1 files 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 <stddef.h>
+#include <inttypes.h>
+
#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.