编写了一个小小的Gobject程序,运行是出现错误:
(process:23258): GLib-GObject-WARNING **: specified class size for type `CatType' is smaller than the parent type's `GObject' class size
type = 0-----------------------------------g_type_register_static的返回为0
(process:23258): GLib-GObject-CRITICAL **: g_object_new: assertion `G_TYPE_IS_OBJECT (object_type)' failed
查了好久,突然发现原来错在:
struct _Cat
{
GTypeInstance parent;
.......................
};
struct _CatClass
{
GTypeClass parent_class;
..........................
};
分别改成是:
struct _Cat
{
GObject parent;
.......................
};
struct _CatClass
{
GObjectClass parent_class;
..........................
};
就好了
specified class size for type `CatType' is smaller than the parent type's `GObject
最新推荐文章于 2025-04-03 21:42:22 发布
本文介绍了在使用GObject库时遇到的一个常见错误——类型大小不匹配的问题,并给出了正确的GObject子类结构体定义方式。
3万+

被折叠的 条评论
为什么被折叠?



