bind_with_mapping creates invalid C code
Submitted by Fabian Sturm
Link to original bug (#664601)
Description
Hi,
I have the code below, which creates invalid C code that can not compile:
Vala:
view_settings.bind_with_mapping (VIEW_BACKGROUND_COLOR, bg_color_button, "color", GLib.SettingsBindFlags.DEFAULT, string_to_color, color_to_string, null);
Generated C code:
g_settings_bind_with_mapping (tmp12, VIEW_BACKGROUND_COLOR, tmp13, "color", G_SETTINGS_BIND_DEFAULT, string_to_color, self, color_to_string, self, NULL);
Original C code I tried to port to vala:
g_settings_bind_with_mapping (view_settings, VIEW_BACKGROUND_COLOR, bg_color_button, "color", G_SETTINGS_BIND_DEFAULT, string_to_color, color_to_string, NULL, NULL);
The compiler error is:
preferences-dialog.c: In function 'preferences_dialog_construct': preferences-dialog.c:299:2: warning: passing argument 7 of 'g_settings_bind_with_mapping' from incompatible pointer type [enabled by default] /usr/include/glib-2.0/gio/gsettings.h:246:25: note: expected 'GSettingsBindSetMapping' but argument is of type 'struct PreferencesDialog *' preferences-dialog.c:299:2: warning: passing argument 9 of 'g_settings_bind_with_mapping' from incompatible pointer type [enabled by default] /usr/include/glib-2.0/gio/gsettings.h:246:25: note: expected 'GDestroyNotify' but argument is of type 'struct PreferencesDialog *' preferences-dialog.c:299:2: error: too many arguments to function 'g_settings_bind_with_mapping' /usr/include/glib-2.0/gio/gsettings.h:246:25: note: declared here preferences-dialog.c: In function 'preferences_dialog_pd_transp_radio_toggle_cb': preferences-dialog.c:472:6: warning: assignment discards 'const' qualifier from pointer target type [enabled by default] preferences-dialog.c:475:67: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] make: *** [preferences-dialog.o] Error 1
Sincerely Fabian
Version: 0.14.x