操作系统 = linux (Fuduntu 2013.2)
我正在尝试在我的程序中使用 GList,但是当我调用 g_list_append 时出现此错误
error: invalid conversion from ‘const void*’ to ‘gpointer {aka void*}’ [-fpermissive]
In file included from /usr/include/glib-2.0/glib/ghash.h:35:0,
from /usr/include/glib-2.0/glib.h:52,
from /usr/include/glib-2.0/gobject/gbinding.h:30,
from /usr/include/glib-2.0/glib-object.h:25,
from /usr/include/glib-2.0/gio/gioenums.h:30,
from /usr/include/glib-2.0/gio/giotypes.h:30,
from /usr/include/glib-2.0/gio/gio.h:28,
from /usr/include/gtk-2.0/gdk/gdkapplaunchcontext.h:30,
from /usr/include/gtk-2.0/gdk/gdk.h:32,
from /usr/include/gtk-2.0/gtk/gtk.h:32,
from main.cpp:4:
/usr/include/glib-2.0/glib/glist.h:61:10: error: initializing argument 2 of ‘GList* g_list_append(GList*, gpointer)’ [-fpermissive]
这是包含 g_list_append 的代码部分
#include<iostream>
#include <stdio.h>
#include<gtk/gtk.h>
#include<glibmm.h>
int main(){
GList *glist_forleg = NULL;
glist_forleg = g_list_append(glist_forleg, "A1");
return 0;
}
编译
g++ -o kabel main.cpp strukt.cpp -lm -Wall `pkg-config --cflags --libs glibmm-2.4` `pkg-config --cflags --libs gtk+-2.0`