if(xmlStrEquals(cur->name, (const xmlChar *) "check")) // Find out which type it is
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, xmlGetProp(cur,"name"))),(gboolean) xmlGetProp(cur,"value"));
else if(xmlStrEquals(cur->name, (const xmlChar *) "spin"))
gtk_adjustment_set_value(GTK_ADJUSTMENT (gtk_builder_get_object (builder, xmlGetProp(cur,"name"))),(gdouble) xmlGetProp(cur,"value"));
else if(xmlStrEquals(cur->name, (const xmlChar *) "combo"))
gtk_combo_box_set_active(GTK_COMBO_BOX (gtk_builder_get_object (builder, xmlGetProp(cur,"name"))),(gint) xmlGetProp(cur,"value"));
以下3個錯誤對應於上述3個if語句。編譯器類型警告和錯誤
main.c:125: warning: cast from pointer to integer of different size
main.c:130: error: pointer value used where a floating point value was expected
main.c:139: warning: cast from pointer to integer of different size
如果你允許我提取違規部分:
(gboolean) xmlGetProp(cur,"value")
(gdouble) xmlGetProp(cur,"value")
(gint) xmlGetProp(cur,"value")
爲什麼這些類型轉換導致這些錯誤?我該如何解決它們?
嘗試使用(gboolean *)
等從GTK的線沿線收到警告:
warning: passing argument 2 of ‘gtk_toggle_button_set_active’ makes integer from pointer without a cast
/usr/include/gtk-2.0/gtk/gtktogglebutton.h:82: note: expected ‘gboolean’ but argument is of type ‘gboolean *’
error: incompatible type for argument 2 of ‘gtk_adjustment_set_value’
/usr/include/gtk-2.0/gtk/gtkadjustment.h:93: note: expected ‘gdouble’ but argument is of type ‘gdouble *’
warning: passing argument 2 of ‘gtk_combo_box_set_active’ makes integer from pointer without a cast
/usr/include/gtk-2.0/gtk/gtkcombobox.h:99: note: expected ‘gint’ but argument is of type ‘gint *’
抱歉,我以爲'(類型)variable'是用通常的方法? – 2011-04-29 20:40:41