我正在处理类似这样的事情,但它是抛出错误。如何将数组添加到没有变量的GSList?
我只是把数组放在一个变量中,并以这种方式传递,但我正在查看几乎500行,如未图案化的数据。 (所以我不能使用循环)
此外,使用GSList整点是为了避免交错数组
list43333 = g_slist_append(list43333,{11,12,13,14,15,17,18,20,22,25,30});
编辑的限制:与铸造`(INT [])得出:
csgtk.h:14: warning: data definition has no type or storage class
csgtk.h:14: warning: type defaults to ‘int’ in declaration of ‘list43333’
csgtk.h:14: error: conflicting types for ‘list43333’
csgtk.h:12: note: previous definition of ‘list43333’ was here
csgtk.h:14: warning: passing argument 1 of ‘g_slist_append’ makes pointer from integer without a cast
/usr/include/glib-2.0/glib/gslist.h:52: note: expected ‘struct GSList *’ but argument is of type ‘int’
csgtk.h:14: warning: initialization makes integer from pointer without a cast
csgtk.h:14: error: initializer element is not constant
编辑:文字复制粘贴来显示它不超出范围(注意,这是在.h文件中的顶级):
GSList * list43333 = NULL;
list43333 = g_slist_prepend(list43333,(int[]){});
主文件
#include "csgtk.h"
GHashTable * widgetbuffer;
[...]
但是,如果我添加了一个数组不会意味着它会都在同GSlist项目结束了? – 2011-05-02 16:27:43
我收到错误,更新了主帖。 – 2011-05-02 16:33:09
之后我可以使用'g_slist_prepend()'然后'g_slist_reverse()'来解决性能问题,但是我仍然无法运行它。 – 2011-05-02 18:04:39