gst/gstutils.h: Try to fix 'dereferencing type-punned pointer will break strict alias...
authorTim-Philipp Müller <tim@centricular.net>
Fri, 9 May 2008 18:25:44 +0000 (18:25 +0000)
committerTim-Philipp Müller <tim@centricular.net>
Fri, 9 May 2008 18:25:44 +0000 (18:25 +0000)
Original commit message from CVS:
* gst/gstutils.h: (GST_BOILERPLATE_FULL):
Try to fix 'dereferencing type-punned pointer will break strict
aliasing rules' warnings with C++ compilers and GLib >= 2.14.0: GLib
changed the default GType typedef from gulong to gsize at some point,
but kept GType typedef'ed to gulong for C++ for ABI reasons; the
g_once_* functions all take a gsize * though, so work around the type
mismatch for C++ by doing everything in gsize and casting to GType
later.

ChangeLog
gst/gstutils.h

index b7a8fa6..a60af45 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2008-05-09  Tim-Philipp Müller  <tim.muller at collabora co uk>
+
+       * gst/gstutils.h: (GST_BOILERPLATE_FULL):
+         Try to fix 'dereferencing type-punned pointer will break strict
+         aliasing rules' warnings with C++ compilers and GLib >= 2.14.0: GLib
+         changed the default GType typedef from gulong to gsize at some point,
+         but kept GType typedef'ed to gulong for C++ for ABI reasons; the
+         g_once_* functions all take a gsize * though, so work around the type
+         mismatch for C++ by doing everything in gsize and casting to GType
+         later.
+
 2008-05-09  Jan Schmidt  <jan.schmidt@sun.com>
 
        * plugins/elements/gstmultiqueue.c:
index 23c4bcd..c6ed717 100644 (file)
@@ -137,8 +137,11 @@ GType type_as_function ## _get_type (void);                                \
 GType                                                                  \
 type_as_function ## _get_type (void)                                   \
 {                                                                      \
-  static volatile GType object_type = 0;                               \
-  if (__gst_once_init_enter ((gsize *) &object_type)) {                        \
+  /* The typedef for GType may be gulong or gsize, depending on the    \
+   * system and whether the compiler is c++ or not. The g_once_init_*  \
+   * functions always take a gsize * though ... */                     \
+  static volatile gsize gonce_data;                                    \
+  if (__gst_once_init_enter (&gonce_data)) {                           \
     GType _type;                                                       \
     _type = gst_type_register_static_full (parent_type_macro,           \
         g_intern_static_string (#type),                                        \
@@ -154,9 +157,9 @@ type_as_function ## _get_type (void)                                        \
         NULL,                                                           \
         (GTypeFlags) 0);                                               \
     additional_initializations (_type);                                        \
-    __gst_once_init_leave ((gsize *) &object_type, (gsize) _type);      \
+    __gst_once_init_leave (&gonce_data, (gsize) _type);                        \
   }                                                                    \
-  return object_type;                                                  \
+  return (GType) gonce_data;                                           \
 }
 
 #define __GST_DO_NOTHING(type) /* NOP */