[glib/glib-2-54] gtype: cast *_init functions to void(*)(void) first



commit cdcd6be206105b9cfbe745a8a4e8a12fa48db487
Author: Lubomir Rintel <lkundrak v3 sk>
Date:   Wed Feb 7 17:27:54 2018 +0000

    gtype: cast *_init functions to void(*)(void) first
    
    The *_init() functions have prototypes incompatible with *InitFunc types they
    are being cast to. This upsets GCC 8's -Wcast-function-type that's enabled by
    default with -Wextra.
    
    Let's not have the public header files emit a warning and neutralize it by
    doing a void(*)(void) cast first.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=793272

 gobject/gtype.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/gobject/gtype.h b/gobject/gtype.h
index 89c1bec16..af1496c71 100644
--- a/gobject/gtype.h
+++ b/gobject/gtype.h
@@ -1790,7 +1790,7 @@ guint     g_type_get_type_registration_serial (void);
  */
 #define G_IMPLEMENT_INTERFACE(TYPE_IFACE, iface_init)       { \
   const GInterfaceInfo g_implement_interface_info = { \
-    (GInterfaceInitFunc) iface_init, NULL, NULL \
+    (GInterfaceInitFunc)(void (*)(void)) iface_init, NULL, NULL \
   }; \
   g_type_add_interface_static (g_define_type_id, TYPE_IFACE, &g_implement_interface_info); \
 }
@@ -1974,9 +1974,9 @@ type_name##_get_type (void) \
         g_type_register_static_simple (TYPE_PARENT, \
                                        g_intern_static_string (#TypeName), \
                                        sizeof (TypeName##Class), \
-                                       (GClassInitFunc) type_name##_class_intern_init, \
+                                       (GClassInitFunc)(void (*)(void)) type_name##_class_intern_init, \
                                        sizeof (TypeName), \
-                                       (GInstanceInitFunc) type_name##_init, \
+                                       (GInstanceInitFunc)(void (*)(void)) type_name##_init, \
                                        (GTypeFlags) flags); \
       { /* custom code follows */
 #define _G_DEFINE_TYPE_EXTENDED_END()  \
@@ -2008,7 +2008,7 @@ type_name##_get_type (void) \
         g_type_register_static_simple (G_TYPE_INTERFACE, \
                                        g_intern_static_string (#TypeName), \
                                        sizeof (TypeName##Interface), \
-                                       (GClassInitFunc)type_name##_default_init, \
+                                       (GClassInitFunc)(GVoidFunc)type_name##_default_init, \
                                        0, \
                                        (GInstanceInitFunc)NULL, \
                                        (GTypeFlags) 0); \


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]