Skip to content

Commit d47d837

Browse files
committed
patch 7.4.2358
Problem: Compiler warnings with Solaris Studio when using GTK3. Solution: Define FUNC2GENERIC depending on the system. (Kazunobu Kuriyama)
1 parent 4664371 commit d47d837

File tree

4 files changed

+40
-12
lines changed

4 files changed

+40
-12
lines changed

src/gui.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,3 +541,29 @@ typedef enum
541541
# define CONVERT_FROM_UTF8(String) (String)
542542
# define CONVERT_FROM_UTF8_FREE(String) ((String) = (char_u *)NULL)
543543
#endif /* FEAT_GUI_GTK */
544+
545+
#ifdef FEAT_GUI_GTK
546+
/*
547+
* The second parameter of g_signal_handlers_disconnect_by_func() is supposed
548+
* to be a function pointer which was passed to g_signal_connect_*() somewhere
549+
* previously, and hence it must be of type GCallback, i.e., void (*)(void).
550+
*
551+
* Meanwhile, g_signal_handlers_disconnect_by_func() is a macro calling
552+
* g_signal_handlers_disconnect_matched(), and the second parameter of the
553+
* former is to be passed to the sixth parameter of the latter the type of
554+
* which, however, is declared as void * in the function signature.
555+
*
556+
* While the ISO C Standard does not require that function pointers be
557+
* interconvertible to void *, widely-used compilers such as gcc and clang
558+
* do such conversion implicitly and automatically on some platforms without
559+
* issuing any warning.
560+
*
561+
* For Solaris Studio, that is not the case. An explicit type cast is needed
562+
* to suppress warnings on that particular conversion.
563+
*/
564+
# if defined(__SUNPRO_C) && defined(USE_GTK3)
565+
# define FUNC2GENERIC(func) (void *)(func)
566+
# else
567+
# define FUNC2GENERIC(func) G_CALLBACK(func)
568+
# endif
569+
#endif /* FEAT_GUI_GTK */

src/gui_beval.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ removeEventHandler(BalloonEval *beval)
508508
/* LINTED: avoid warning: dubious operation on enum */
509509
# if GTK_CHECK_VERSION(3,0,0)
510510
g_signal_handlers_disconnect_by_func(G_OBJECT(beval->target),
511-
G_CALLBACK(target_event_cb),
511+
FUNC2GENERIC(target_event_cb),
512512
beval);
513513
# else
514514
gtk_signal_disconnect_by_func((GtkObject*)(beval->target),
@@ -522,7 +522,7 @@ removeEventHandler(BalloonEval *beval)
522522
/* LINTED: avoid warning: dubious operation on enum */
523523
# if GTK_CHECK_VERSION(3,0,0)
524524
g_signal_handlers_disconnect_by_func(G_OBJECT(gui.mainwin),
525-
G_CALLBACK(mainwin_event_cb),
525+
FUNC2GENERIC(mainwin_event_cb),
526526
beval);
527527
# else
528528
gtk_signal_disconnect_by_func((GtkObject*)(gui.mainwin),

src/gui_gtk_f.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -505,18 +505,18 @@ gtk_form_unrealize(GtkWidget *widget)
505505
{
506506
#if GTK_CHECK_VERSION(3,0,0)
507507
g_signal_handlers_disconnect_by_func(G_OBJECT(child->widget),
508-
G_CALLBACK(gtk_form_child_map),
508+
FUNC2GENERIC(gtk_form_child_map),
509509
child);
510510
g_signal_handlers_disconnect_by_func(G_OBJECT(child->widget),
511-
G_CALLBACK(gtk_form_child_unmap),
511+
FUNC2GENERIC(gtk_form_child_unmap),
512512
child);
513513
#else
514514
gtk_signal_disconnect_by_func(GTK_OBJECT(child->widget),
515-
GTK_SIGNAL_FUNC(gtk_form_child_map),
516-
child);
515+
GTK_SIGNAL_FUNC(gtk_form_child_map),
516+
child);
517517
gtk_signal_disconnect_by_func(GTK_OBJECT(child->widget),
518-
GTK_SIGNAL_FUNC(gtk_form_child_unmap),
519-
child);
518+
GTK_SIGNAL_FUNC(gtk_form_child_unmap),
519+
child);
520520
#endif
521521

522522
gdk_window_set_user_data(child->window, NULL);
@@ -793,14 +793,14 @@ gtk_form_remove(GtkContainer *container, GtkWidget *widget)
793793
{
794794
#if GTK_CHECK_VERSION(3,0,0)
795795
g_signal_handlers_disconnect_by_func(G_OBJECT(child->widget),
796-
G_CALLBACK(&gtk_form_child_map), child);
796+
FUNC2GENERIC(&gtk_form_child_map), child);
797797
g_signal_handlers_disconnect_by_func(G_OBJECT(child->widget),
798-
G_CALLBACK(&gtk_form_child_unmap), child);
798+
FUNC2GENERIC(&gtk_form_child_unmap), child);
799799
#else
800800
gtk_signal_disconnect_by_func(GTK_OBJECT(child->widget),
801-
GTK_SIGNAL_FUNC(&gtk_form_child_map), child);
801+
GTK_SIGNAL_FUNC(&gtk_form_child_map), child);
802802
gtk_signal_disconnect_by_func(GTK_OBJECT(child->widget),
803-
GTK_SIGNAL_FUNC(&gtk_form_child_unmap), child);
803+
GTK_SIGNAL_FUNC(&gtk_form_child_unmap), child);
804804
#endif
805805

806806
/* FIXME: This will cause problems for reparenting NO_WINDOW

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,8 @@ static char *(features[]) =
763763

764764
static int included_patches[] =
765765
{ /* Add new patch number below this line */
766+
/**/
767+
2358,
766768
/**/
767769
2357,
768770
/**/

0 commit comments

Comments
 (0)